@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,44 +26,42 @@ 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_74LUB4XX_exports = {};
30
- __export(chunk_74LUB4XX_exports, {
29
+ var chunk_BRPS327A_exports = {};
30
+ __export(chunk_BRPS327A_exports, {
31
31
  ensureCanConnectToDatabase: () => ensureCanConnectToDatabase,
32
32
  ensureDatabaseExists: () => ensureDatabaseExists,
33
33
  getDbLocation: () => getDbLocation,
34
34
  parseDatasourceInfo: () => parseDatasourceInfo,
35
35
  prettifyProvider: () => prettifyProvider
36
36
  });
37
- module.exports = __toCommonJS(chunk_74LUB4XX_exports);
37
+ module.exports = __toCommonJS(chunk_BRPS327A_exports);
38
38
  var import_chunk_TWPTG4XS = require("./chunk-TWPTG4XS.js");
39
39
  var import_chunk_SKRR5WT4 = require("./chunk-SKRR5WT4.js");
40
+ var import_node_path = __toESM(require("node:path"));
40
41
  var import_internals = require("@prisma/internals");
41
- var import_path = __toESM(require("path"));
42
- function parseDatasourceInfo(datasource) {
42
+ function parseDatasourceInfo(datasource, config) {
43
+ const url = config.datasource.url;
43
44
  if (!datasource) {
44
45
  return {
45
46
  name: void 0,
46
47
  prettyProvider: void 0,
47
48
  dbName: void 0,
48
49
  dbLocation: void 0,
49
- url: void 0,
50
+ url,
50
51
  schema: void 0,
51
- schemas: void 0,
52
- configDir: void 0
52
+ schemas: void 0
53
53
  };
54
54
  }
55
55
  const prettyProvider = prettifyProvider(datasource.provider);
56
- const url = (0, import_internals.getEffectiveUrl)(datasource).value;
57
- if (!url || datasource.provider === "sqlserver") {
56
+ if (datasource.provider === "sqlserver") {
58
57
  return {
59
58
  name: datasource.name,
60
59
  prettyProvider,
61
60
  dbName: void 0,
62
61
  dbLocation: void 0,
63
- url: url || void 0,
62
+ url,
64
63
  schema: void 0,
65
- schemas: datasource.schemas,
66
- configDir: import_path.default.dirname(datasource.sourceFilePath)
64
+ schemas: datasource.schemas
67
65
  };
68
66
  }
69
67
  try {
@@ -85,7 +83,7 @@ function parseDatasourceInfo(datasource) {
85
83
  url,
86
84
  schema,
87
85
  schemas: datasource.schemas,
88
- configDir: import_path.default.dirname(datasource.sourceFilePath)
86
+ configDir: import_node_path.default.dirname(datasource.sourceFilePath)
89
87
  };
90
88
  if (datasource.provider === "postgresql" && datasourceInfo.dbName === void 0) {
91
89
  datasourceInfo.dbName = "postgres";
@@ -99,32 +97,23 @@ function parseDatasourceInfo(datasource) {
99
97
  dbLocation: void 0,
100
98
  url,
101
99
  schema: void 0,
102
- schemas: datasource.schemas,
103
- configDir: import_path.default.dirname(datasource.sourceFilePath)
100
+ schemas: datasource.schemas
104
101
  };
105
102
  }
106
103
  }
107
- async function ensureCanConnectToDatabase(datasource) {
108
- if (!datasource) {
109
- throw new Error(`A datasource block is missing in the Prisma schema file.`);
110
- }
111
- const schemaDir = import_path.default.dirname(datasource.sourceFilePath);
112
- const url = getConnectionUrl(datasource);
113
- const canConnect = await (0, import_internals.canConnectToDatabase)(url, schemaDir);
104
+ async function ensureCanConnectToDatabase(pathResolutionRoot, config) {
105
+ const url = config.datasource.url;
106
+ const canConnect = await (0, import_internals.canConnectToDatabase)(url, pathResolutionRoot);
114
107
  if (canConnect === true) {
115
- return true;
108
+ return;
116
109
  } else {
117
110
  const { code, message } = canConnect;
118
111
  throw new Error(`${code}: ${message}`);
119
112
  }
120
113
  }
121
- async function ensureDatabaseExists(datasource) {
122
- if (!datasource) {
123
- throw new Error(`A datasource block is missing in the Prisma schema file.`);
124
- }
125
- const schemaDir = import_path.default.dirname(datasource.sourceFilePath);
126
- const url = getConnectionUrl(datasource);
127
- const canConnect = await (0, import_internals.canConnectToDatabase)(url, schemaDir);
114
+ async function ensureDatabaseExists(pathResolutionRoot, provider, config) {
115
+ const url = config.datasource.url;
116
+ const canConnect = await (0, import_internals.canConnectToDatabase)(url, pathResolutionRoot);
128
117
  if (canConnect === true) {
129
118
  return;
130
119
  }
@@ -132,13 +121,13 @@ async function ensureDatabaseExists(datasource) {
132
121
  if (code !== "P1003") {
133
122
  throw new Error(`${code}: ${message}`);
134
123
  }
135
- if (await (0, import_internals.createDatabase)(url, schemaDir)) {
136
- if (datasource.provider === "sqlserver") {
124
+ if (await (0, import_internals.createDatabase)(url, pathResolutionRoot)) {
125
+ if (provider === "sqlserver") {
137
126
  return `SQL Server database created.
138
127
  `;
139
128
  }
140
129
  const credentials = (0, import_internals.uriToCredentials)(url);
141
- const prettyProvider = prettifyProvider(datasource.provider);
130
+ const prettyProvider = prettifyProvider(provider);
142
131
  let message2 = `${prettyProvider} database${credentials.database ? ` ${credentials.database} ` : " "}created`;
143
132
  const dbLocation = getDbLocation(credentials);
144
133
  if (dbLocation) {
@@ -181,14 +170,3 @@ function prettifyProvider(provider) {
181
170
  return `MongoDB`;
182
171
  }
183
172
  }
184
- function getConnectionUrl(datasource) {
185
- const url = (0, import_internals.getEffectiveUrl)(datasource);
186
- if (!url.value) {
187
- if (url.fromEnvVar) {
188
- throw new Error(`Environment variable '${url.fromEnvVar}' with database connection URL was not found.`);
189
- } else {
190
- throw new Error(`Datasource is missing a database connection URL.`);
191
- }
192
- }
193
- return url.value;
194
- }
@@ -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_CQ6GMT2G_exports = {};
30
+ __export(chunk_CQ6GMT2G_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_CQ6GMT2G_exports);
34
+ var import_chunk_3MCWUFUJ = require("./chunk-3MCWUFUJ.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");
@@ -40,17 +40,15 @@ var import_path = __toESM(require("path"));
40
40
  var helpOptions = (0, import_internals.format)(
41
41
  `${(0, import_chunk_SKRR5WT4.bold)("Usage")}
42
42
 
43
- ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma db execute [options]
43
+ ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma db execute [options]
44
+
45
+ The datasource URL configuration is read from the Prisma config file (e.g., ${(0, import_chunk_SKRR5WT4.italic)("prisma.config.ts")}).
44
46
 
45
47
  ${(0, import_chunk_SKRR5WT4.bold)("Options")}
46
48
 
47
49
  -h, --help Display this help message
48
50
  --config Custom path to your Prisma config file
49
51
 
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
53
-
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
56
54
 
@@ -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,25 +80,16 @@ ${(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
- async parse(argv, config) {
92
+ async parse(argv, config, configDir) {
104
93
  const args = (0, import_internals.arg)(
105
94
  argv,
106
95
  {
@@ -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,16 @@ ${(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
- });
112
+ const validatedConfig = (0, import_internals.validatePrismaConfigWithDatasource)({ config, cmd });
132
113
  if (args["--stdin"] && args["--file"]) {
133
114
  throw new Error(
134
- `--stdin and --file cannot be used at the same time. Only 1 must be provided.
115
+ `--stdin and --file cannot be used at the same time. Only 1 must be provided.
135
116
  See \`${(0, import_chunk_SKRR5WT4.green)((0, import_internals.getCommandWithExecutor)("prisma db execute -h"))}\``
136
117
  );
137
118
  } else if (!args["--stdin"] && !args["--file"]) {
138
119
  throw new Error(
139
120
  `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
121
  See \`${(0, import_chunk_SKRR5WT4.green)((0, import_internals.getCommandWithExecutor)("prisma db execute -h"))}\``
152
122
  );
153
123
  }
@@ -167,28 +137,12 @@ See \`${(0, import_chunk_SKRR5WT4.green)((0, import_internals.getCommandWithExec
167
137
  if (args["--stdin"]) {
168
138
  script = await import_consumers.default.text(process.stdin);
169
139
  }
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
- };
190
- }
191
- const migrate = await import_chunk_D6LYHB65.Migrate.setup({ schemaEngineConfig: config, extensions: config["extensions"] });
140
+ (0, import_internals.checkUnsupportedDataProxy)({ cmd, validatedConfig });
141
+ const datasourceType = {
142
+ tag: "url",
143
+ url: validatedConfig.datasource.url
144
+ };
145
+ const migrate = await import_chunk_3MCWUFUJ.Migrate.setup({ schemaEngineConfig: config, extensions: config["extensions"], configDir });
192
146
  try {
193
147
  await migrate.engine.dbExecute({
194
148
  script,
@@ -16,11 +16,11 @@ 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_EJG7GKM7_exports = {};
20
- __export(chunk_EJG7GKM7_exports, {
19
+ var chunk_DCXZOUQV_exports = {};
20
+ __export(chunk_DCXZOUQV_exports, {
21
21
  DbCommand: () => DbCommand
22
22
  });
23
- module.exports = __toCommonJS(chunk_EJG7GKM7_exports);
23
+ module.exports = __toCommonJS(chunk_DCXZOUQV_exports);
24
24
  var import_chunk_SKRR5WT4 = require("./chunk-SKRR5WT4.js");
25
25
  var import_internals = require("@prisma/internals");
26
26
  var DbCommand = class _DbCommand {
@@ -63,7 +63,7 @@ ${(0, import_chunk_SKRR5WT4.bold)("Examples")}
63
63
  Run \`prisma db execute\`
64
64
  ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma db execute
65
65
  `);
66
- async parse(argv, config) {
66
+ async parse(argv, config, configDir) {
67
67
  const args = (0, import_internals.arg)(argv, {
68
68
  "--help": Boolean,
69
69
  "-h": "--help",
@@ -80,7 +80,7 @@ ${(0, import_chunk_SKRR5WT4.bold)("Examples")}
80
80
  const cmd = this.cmds[args._[0]];
81
81
  if (cmd) {
82
82
  const argsForCmd = args["--preview-feature"] ? [...args._.slice(1), `--preview-feature`] : args._.slice(1);
83
- return cmd.parse(argsForCmd, config);
83
+ return cmd.parse(argsForCmd, config, configDir);
84
84
  }
85
85
  return (0, import_internals.unknownCommand)(_DbCommand.help, args._[0]);
86
86
  }
@@ -16,11 +16,11 @@ 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_LLO7YF56_exports = {};
20
- __export(chunk_LLO7YF56_exports, {
19
+ var chunk_DYXUXG3K_exports = {};
20
+ __export(chunk_DYXUXG3K_exports, {
21
21
  MigrateCommand: () => MigrateCommand
22
22
  });
23
- module.exports = __toCommonJS(chunk_LLO7YF56_exports);
23
+ module.exports = __toCommonJS(chunk_DYXUXG3K_exports);
24
24
  var import_chunk_SKRR5WT4 = require("./chunk-SKRR5WT4.js");
25
25
  var import_internals = require("@prisma/internals");
26
26
  var MigrateCommand = class _MigrateCommand {
@@ -32,7 +32,7 @@ var MigrateCommand = class _MigrateCommand {
32
32
  }
33
33
  static help = (0, import_internals.format)(`
34
34
  Update the database schema with migrations
35
-
35
+
36
36
  ${(0, import_chunk_SKRR5WT4.bold)("Usage")}
37
37
 
38
38
  ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma migrate [command] [options]
@@ -45,7 +45,7 @@ ${(0, import_chunk_SKRR5WT4.bold)("Commands for development")}
45
45
 
46
46
  ${(0, import_chunk_SKRR5WT4.bold)("Commands for production/staging")}
47
47
 
48
- deploy Apply pending migrations to the database
48
+ deploy Apply pending migrations to the database
49
49
  status Check the status of your database migrations
50
50
  resolve Resolve issues with database migrations, i.e. baseline, failed migration, hotfix
51
51
 
@@ -82,7 +82,7 @@ ${(0, import_chunk_SKRR5WT4.bold)("Examples")}
82
82
  --to-url "postgresql://login:password@localhost:5432/db" \\
83
83
  --script
84
84
  `);
85
- async parse(argv, config) {
85
+ async parse(argv, config, configDir) {
86
86
  const args = (0, import_internals.arg)(argv, {
87
87
  "--help": Boolean,
88
88
  "-h": "--help",
@@ -106,7 +106,7 @@ ${(0, import_chunk_SKRR5WT4.bold)("Examples")}
106
106
  const filteredArgs = args._.filter((item) => item !== "--preview-feature");
107
107
  argsForCmd = filteredArgs.slice(1);
108
108
  }
109
- return cmd.parse(argsForCmd, config);
109
+ return cmd.parse(argsForCmd, config, configDir);
110
110
  }
111
111
  return (0, import_internals.unknownCommand)(_MigrateCommand.help, commandName);
112
112
  }
@@ -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_GSX25HRL_exports = {};
30
- __export(chunk_GSX25HRL_exports, {
29
+ var chunk_ENVEA7LT_exports = {};
30
+ __export(chunk_ENVEA7LT_exports, {
31
31
  EngineError: () => EngineError,
32
32
  SchemaEngineCLI: () => SchemaEngineCLI
33
33
  });
34
- module.exports = __toCommonJS(chunk_GSX25HRL_exports);
35
- var import_chunk_AXR7LS2N = require("./chunk-AXR7LS2N.js");
34
+ module.exports = __toCommonJS(chunk_ENVEA7LT_exports);
35
+ var import_chunk_PEUHUCS4 = require("./chunk-PEUHUCS4.js");
36
36
  var import_chunk_L6KOIJJ5 = require("./chunk-L6KOIJJ5.js");
37
37
  var import_chunk_SKRR5WT4 = require("./chunk-SKRR5WT4.js");
38
38
  var import_debug = __toESM(require("@prisma/debug"));
@@ -64,9 +64,7 @@ var SchemaEngineCLI = class _SchemaEngineCLI {
64
64
  initPromise;
65
65
  enabledPreviewFeatures;
66
66
  extensionConfig;
67
- // `latestSchema` is set to the latest schema that was used in `introspect()`
68
- // TODO: remove, it's not used anywhere.
69
- latestSchema;
67
+ configDir;
70
68
  // `isRunning` is set to true when the engine is initialized, and set to false when the engine is stopped
71
69
  isRunning = false;
72
70
  constructor({
@@ -74,7 +72,8 @@ var SchemaEngineCLI = class _SchemaEngineCLI {
74
72
  schemaContext,
75
73
  datasource,
76
74
  enabledPreviewFeatures,
77
- extensions
75
+ extensions,
76
+ configDir
78
77
  }) {
79
78
  this.schemaContext = schemaContext;
80
79
  this.datasource = datasource;
@@ -84,6 +83,7 @@ var SchemaEngineCLI = class _SchemaEngineCLI {
84
83
  this.debug = debug;
85
84
  this.enabledPreviewFeatures = enabledPreviewFeatures;
86
85
  this.extensionConfig = extensions ? { types: extensions.flatMap((ext) => ext.types) } : void 0;
86
+ this.configDir = configDir;
87
87
  }
88
88
  static setup(input) {
89
89
  return Promise.resolve(new _SchemaEngineCLI(input));
@@ -181,14 +181,13 @@ var SchemaEngineCLI = class _SchemaEngineCLI {
181
181
  // cannot be undefined
182
182
  namespaces
183
183
  }) {
184
- this.latestSchema = schema;
185
184
  try {
186
185
  const introspectResult = await this.runCommand(
187
186
  this.getRPCPayload("introspect", { schema, force, compositeTypeDepth, namespaces, baseDirectoryPath })
188
187
  );
189
188
  const { views } = introspectResult;
190
189
  if (views) {
191
- await (0, import_chunk_AXR7LS2N.handleViewsIO)({ views, viewsDirectoryPath });
190
+ await (0, import_chunk_PEUHUCS4.handleViewsIO)({ views, viewsDirectoryPath });
192
191
  }
193
192
  return introspectResult;
194
193
  } finally {
@@ -321,9 +320,7 @@ var SchemaEngineCLI = class _SchemaEngineCLI {
321
320
  const binaryPath = await (0, import_internals.resolveBinary)(import_internals.BinaryType.SchemaEngineBinary);
322
321
  debugRpc("starting Schema engine with binary: " + binaryPath);
323
322
  const args = [];
324
- let projectDir = process.cwd();
325
323
  if (this.schemaContext) {
326
- projectDir = this.schemaContext.primaryDatasourceDirectory;
327
324
  const schemaArgs = this.schemaContext.schemaFiles.flatMap(([path]) => ["--datamodels", path]);
328
325
  args.push(...schemaArgs);
329
326
  }
@@ -337,7 +334,7 @@ var SchemaEngineCLI = class _SchemaEngineCLI {
337
334
  args.push(...["--extension-types", JSON.stringify(this.extensionConfig)]);
338
335
  }
339
336
  this.child = (0, import_child_process.spawn)(binaryPath, args, {
340
- cwd: projectDir,
337
+ cwd: this.configDir,
341
338
  stdio: ["pipe", "pipe", this.debug ? process.stderr : "pipe"],
342
339
  env: {
343
340
  // The following environment variables can be overridden by the user.