@prisma/migrate 6.19.0-integration-next.5 → 6.19.0-integration-engines-6-19-0-2-push-qtpkxwkvolmz-33c9120129ea6df44eaf652b4de9bedd817e3190.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/Migrate.js +3 -3
  2. package/dist/bin.js +27 -26
  3. package/dist/{chunk-AVDCAVMB.js → chunk-3AKRTEIK.js} +7 -7
  4. package/dist/{chunk-I2VUHLTD.js → chunk-6ORQRJLP.js} +45 -14
  5. package/dist/{chunk-RF72HHCJ.js → chunk-7TVX3D4W.js} +6 -6
  6. package/dist/{chunk-TVLHBYPV.js → chunk-BHJMJSM4.js} +6 -6
  7. package/dist/{chunk-W2NKGYXF.js → chunk-D4TRX77Y.js} +9 -7
  8. package/dist/{chunk-RMMTCJSW.js → chunk-D6LYHB65.js} +4 -4
  9. package/dist/{chunk-F4ENFSD2.js → chunk-F2XCBEZ4.js} +11 -9
  10. package/dist/{chunk-NX7CVZ33.js → chunk-J33EXHZB.js} +11 -9
  11. package/dist/{chunk-ZBQSD3YW.js → chunk-NB4FRYRQ.js} +5 -5
  12. package/dist/{chunk-EDBWBKKM.js → chunk-O35BTK6Y.js} +5 -5
  13. package/dist/{chunk-L7EZFBB4.js → chunk-PHXLQVPT.js} +68 -40
  14. package/dist/{chunk-YB32XZV6.js → chunk-R4IWP35Z.js} +6 -6
  15. package/dist/chunk-RR6BKMNO.js +80 -0
  16. package/dist/{chunk-TIVQQZRQ.js → chunk-TW22Y3AA.js} +6 -6
  17. package/dist/{chunk-43R3GFIU.js → chunk-Z27SI4AV.js} +4 -4
  18. package/dist/{chunk-55CU3CV4.js → chunk-ZTIS675B.js} +42 -7
  19. package/dist/commands/DbDrop.js +2 -2
  20. package/dist/commands/DbExecute.js +4 -4
  21. package/dist/commands/DbPull.js +5 -4
  22. package/dist/commands/DbPush.js +4 -4
  23. package/dist/commands/DbSeed.js +3 -3
  24. package/dist/commands/MigrateDeploy.js +4 -4
  25. package/dist/commands/MigrateDev.js +5 -5
  26. package/dist/commands/MigrateDiff.js +4 -4
  27. package/dist/commands/MigrateReset.js +5 -5
  28. package/dist/commands/MigrateResolve.js +4 -4
  29. package/dist/commands/MigrateStatus.js +4 -4
  30. package/dist/index.js +31 -30
  31. package/dist/internals/src/cli/getSchema.d.ts +15 -1
  32. package/dist/migrate/src/utils/replaceOrAddDatasource.d.ts +2 -0
  33. package/dist/migrate/src/utils/replaceOrAddDatasource.test.d.ts +1 -0
  34. package/dist/migrate/src/utils/seed.d.ts +6 -0
  35. package/dist/utils/getDatabaseVersionSafe.js +4 -4
  36. package/dist/utils/introspectSql.js +4 -4
  37. package/dist/utils/replaceOrAddDatasource.js +25 -0
  38. package/dist/utils/replaceOrAddDatasource.test.js +207 -0
  39. package/dist/utils/seed.js +3 -2
  40. package/package.json +11 -11
package/dist/Migrate.js CHANGED
@@ -18,12 +18,12 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var Migrate_exports = {};
20
20
  __export(Migrate_exports, {
21
- Migrate: () => import_chunk_RMMTCJSW.Migrate
21
+ Migrate: () => import_chunk_D6LYHB65.Migrate
22
22
  });
23
23
  module.exports = __toCommonJS(Migrate_exports);
24
- var import_chunk_RMMTCJSW = require("./chunk-RMMTCJSW.js");
25
- var import_chunk_VV4M6AN7 = require("./chunk-VV4M6AN7.js");
24
+ var import_chunk_D6LYHB65 = require("./chunk-D6LYHB65.js");
26
25
  var import_chunk_T64SUJ5L = require("./chunk-T64SUJ5L.js");
26
+ var import_chunk_VV4M6AN7 = require("./chunk-VV4M6AN7.js");
27
27
  var import_chunk_GGA2F64G = require("./chunk-GGA2F64G.js");
28
28
  var import_chunk_23DZXSTI = require("./chunk-23DZXSTI.js");
29
29
  var import_chunk_3WDCTXHL = require("./chunk-3WDCTXHL.js");
package/dist/bin.js CHANGED
@@ -23,41 +23,42 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
23
23
  mod
24
24
  ));
25
25
  var import_chunk_NGQA5JTN = require("./chunk-NGQA5JTN.js");
26
- var import_chunk_ZBQSD3YW = require("./chunk-ZBQSD3YW.js");
27
- var import_chunk_TVLHBYPV = require("./chunk-TVLHBYPV.js");
28
- var import_chunk_F4ENFSD2 = require("./chunk-F4ENFSD2.js");
26
+ var import_chunk_NB4FRYRQ = require("./chunk-NB4FRYRQ.js");
27
+ var import_chunk_BHJMJSM4 = require("./chunk-BHJMJSM4.js");
28
+ var import_chunk_F2XCBEZ4 = require("./chunk-F2XCBEZ4.js");
29
29
  var import_chunk_C3722PDA = require("./chunk-C3722PDA.js");
30
30
  var import_chunk_7CQBDP4H = require("./chunk-7CQBDP4H.js");
31
- var import_chunk_55CU3CV4 = require("./chunk-55CU3CV4.js");
31
+ var import_chunk_ZTIS675B = require("./chunk-ZTIS675B.js");
32
32
  var import_chunk_VAJ4VX67 = require("./chunk-VAJ4VX67.js");
33
- var import_chunk_NX7CVZ33 = require("./chunk-NX7CVZ33.js");
33
+ var import_chunk_J33EXHZB = require("./chunk-J33EXHZB.js");
34
34
  var import_chunk_KRQEFTDT = require("./chunk-KRQEFTDT.js");
35
35
  var import_chunk_UP6FVCDK = require("./chunk-UP6FVCDK.js");
36
- var import_chunk_AVDCAVMB = require("./chunk-AVDCAVMB.js");
37
- var import_chunk_YB32XZV6 = require("./chunk-YB32XZV6.js");
36
+ var import_chunk_3AKRTEIK = require("./chunk-3AKRTEIK.js");
37
+ var import_chunk_R4IWP35Z = require("./chunk-R4IWP35Z.js");
38
38
  var import_chunk_EJG7GKM7 = require("./chunk-EJG7GKM7.js");
39
- var import_chunk_RF72HHCJ = require("./chunk-RF72HHCJ.js");
40
- var import_chunk_I2VUHLTD = require("./chunk-I2VUHLTD.js");
39
+ var import_chunk_7TVX3D4W = require("./chunk-7TVX3D4W.js");
40
+ var import_chunk_6ORQRJLP = require("./chunk-6ORQRJLP.js");
41
41
  var import_chunk_VU5BLQUI = require("./chunk-VU5BLQUI.js");
42
42
  var import_chunk_AHJ2N6BJ = require("./chunk-AHJ2N6BJ.js");
43
43
  var import_chunk_JZ75RIMZ = require("./chunk-JZ75RIMZ.js");
44
+ var import_chunk_RR6BKMNO = require("./chunk-RR6BKMNO.js");
44
45
  var import_chunk_RTGQXNX6 = require("./chunk-RTGQXNX6.js");
45
46
  var import_chunk_JFKDSUIE = require("./chunk-JFKDSUIE.js");
46
47
  var import_chunk_AI6DH66U = require("./chunk-AI6DH66U.js");
47
48
  var import_chunk_LGYRZ6CV = require("./chunk-LGYRZ6CV.js");
48
49
  var import_chunk_2R6DII47 = require("./chunk-2R6DII47.js");
49
- var import_chunk_TIVQQZRQ = require("./chunk-TIVQQZRQ.js");
50
+ var import_chunk_TW22Y3AA = require("./chunk-TW22Y3AA.js");
50
51
  var import_chunk_FBDQVK4W = require("./chunk-FBDQVK4W.js");
51
52
  var import_chunk_3WC4XD74 = require("./chunk-3WC4XD74.js");
52
53
  var import_chunk_2FXU5NZQ = require("./chunk-2FXU5NZQ.js");
53
54
  var import_chunk_74LUB4XX = require("./chunk-74LUB4XX.js");
54
55
  var import_chunk_TWPTG4XS = require("./chunk-TWPTG4XS.js");
55
- var import_chunk_W2NKGYXF = require("./chunk-W2NKGYXF.js");
56
- var import_chunk_L7EZFBB4 = require("./chunk-L7EZFBB4.js");
56
+ var import_chunk_D4TRX77Y = require("./chunk-D4TRX77Y.js");
57
+ var import_chunk_PHXLQVPT = require("./chunk-PHXLQVPT.js");
57
58
  var import_chunk_LLO7YF56 = require("./chunk-LLO7YF56.js");
58
- var import_chunk_RMMTCJSW = require("./chunk-RMMTCJSW.js");
59
- var import_chunk_VV4M6AN7 = require("./chunk-VV4M6AN7.js");
59
+ var import_chunk_D6LYHB65 = require("./chunk-D6LYHB65.js");
60
60
  var import_chunk_T64SUJ5L = require("./chunk-T64SUJ5L.js");
61
+ var import_chunk_VV4M6AN7 = require("./chunk-VV4M6AN7.js");
61
62
  var import_chunk_GGA2F64G = require("./chunk-GGA2F64G.js");
62
63
  var import_chunk_23DZXSTI = require("./chunk-23DZXSTI.js");
63
64
  var import_chunk_3WDCTXHL = require("./chunk-3WDCTXHL.js");
@@ -71,7 +72,7 @@ var import_config = require("@prisma/config");
71
72
  var import_debug = __toESM(require("@prisma/debug"));
72
73
  var import_engines_version = require("@prisma/engines-version");
73
74
  var import_internals = require("@prisma/internals");
74
- var version = "6.19.0-integration-next.5";
75
+ var version = "6.19.0-integration-engines-6-19-0-2-push-qtpkxwkvolmz-33c9120129ea6df44eaf652b4de9bedd817e3190.1";
75
76
  process.on("uncaughtException", (e) => {
76
77
  console.log(e);
77
78
  });
@@ -93,19 +94,19 @@ var args = (0, import_internals.arg)(
93
94
  async function main() {
94
95
  const cli = import_chunk_NGQA5JTN.CLI.new({
95
96
  migrate: import_chunk_LLO7YF56.MigrateCommand.new({
96
- dev: import_chunk_F4ENFSD2.MigrateDev.new(),
97
- status: import_chunk_YB32XZV6.MigrateStatus.new(),
98
- resolve: import_chunk_AVDCAVMB.MigrateResolve.new(),
99
- reset: import_chunk_NX7CVZ33.MigrateReset.new(),
100
- deploy: import_chunk_TVLHBYPV.MigrateDeploy.new(),
101
- diff: import_chunk_55CU3CV4.MigrateDiff.new()
97
+ dev: import_chunk_F2XCBEZ4.MigrateDev.new(),
98
+ status: import_chunk_R4IWP35Z.MigrateStatus.new(),
99
+ resolve: import_chunk_3AKRTEIK.MigrateResolve.new(),
100
+ reset: import_chunk_J33EXHZB.MigrateReset.new(),
101
+ deploy: import_chunk_BHJMJSM4.MigrateDeploy.new(),
102
+ diff: import_chunk_ZTIS675B.MigrateDiff.new()
102
103
  }),
103
104
  db: import_chunk_EJG7GKM7.DbCommand.new({
104
- execute: import_chunk_RF72HHCJ.DbExecute.new(),
105
- pull: import_chunk_I2VUHLTD.DbPull.new(),
106
- push: import_chunk_TIVQQZRQ.DbPush.new(),
105
+ execute: import_chunk_7TVX3D4W.DbExecute.new(),
106
+ pull: import_chunk_6ORQRJLP.DbPull.new(),
107
+ push: import_chunk_TW22Y3AA.DbPush.new(),
107
108
  // drop: DbDrop.new(),
108
- seed: import_chunk_W2NKGYXF.DbSeed.new()
109
+ seed: import_chunk_D4TRX77Y.DbSeed.new()
109
110
  })
110
111
  });
111
112
  const { config, error } = await (0, import_config.loadConfigFromFile)({ configFile: args["--config"] });
@@ -135,7 +136,7 @@ main().then((code) => {
135
136
  cliVersion: version,
136
137
  enginesVersion: import_engines_version.enginesVersion,
137
138
  command: commandArray.join(" "),
138
- getDatabaseVersionSafe: import_chunk_ZBQSD3YW.getDatabaseVersionSafe
139
+ getDatabaseVersionSafe: import_chunk_NB4FRYRQ.getDatabaseVersionSafe
139
140
  }).catch((e) => {
140
141
  if (import_debug.default.enabled("migrate")) {
141
142
  console.error((0, import_chunk_SKRR5WT4.red)((0, import_chunk_SKRR5WT4.bold)("Error: ")) + e.stack);
@@ -16,14 +16,14 @@ 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_AVDCAVMB_exports = {};
20
- __export(chunk_AVDCAVMB_exports, {
19
+ var chunk_3AKRTEIK_exports = {};
20
+ __export(chunk_3AKRTEIK_exports, {
21
21
  MigrateResolve: () => MigrateResolve
22
22
  });
23
- module.exports = __toCommonJS(chunk_AVDCAVMB_exports);
23
+ module.exports = __toCommonJS(chunk_3AKRTEIK_exports);
24
24
  var import_chunk_2FXU5NZQ = require("./chunk-2FXU5NZQ.js");
25
25
  var import_chunk_74LUB4XX = require("./chunk-74LUB4XX.js");
26
- var import_chunk_RMMTCJSW = require("./chunk-RMMTCJSW.js");
26
+ var import_chunk_D6LYHB65 = require("./chunk-D6LYHB65.js");
27
27
  var import_chunk_SKRR5WT4 = require("./chunk-SKRR5WT4.js");
28
28
  var import_internals = require("@prisma/internals");
29
29
  var MigrateResolve = class _MigrateResolve {
@@ -83,7 +83,7 @@ ${(0, import_chunk_SKRR5WT4.bold)("Examples")}
83
83
  if (args["--help"]) {
84
84
  return this.help();
85
85
  }
86
- (0, import_internals.loadEnvFile)({ schemaPath: args["--schema"], printMessage: true, config });
86
+ await (0, import_internals.loadEnvFile)({ schemaPath: args["--schema"], printMessage: true, config });
87
87
  const schemaContext = await (0, import_internals.loadSchemaContext)({
88
88
  schemaPathFromArg: args["--schema"],
89
89
  schemaPathFromConfig: config.schema,
@@ -113,7 +113,7 @@ ${(0, import_chunk_SKRR5WT4.bold)((0, import_chunk_SKRR5WT4.green)((0, import_in
113
113
  if (!adapter) {
114
114
  await (0, import_chunk_74LUB4XX.ensureCanConnectToDatabase)(schemaContext.primaryDatasource);
115
115
  }
116
- const migrate = await import_chunk_RMMTCJSW.Migrate.setup({
116
+ const migrate = await import_chunk_D6LYHB65.Migrate.setup({
117
117
  schemaEngineConfig: config,
118
118
  migrationsDirPath,
119
119
  schemaContext,
@@ -139,7 +139,7 @@ Migration ${args["--applied"]} marked as applied.
139
139
  );
140
140
  }
141
141
  await (0, import_chunk_74LUB4XX.ensureCanConnectToDatabase)(schemaContext.primaryDatasource);
142
- const migrate = await import_chunk_RMMTCJSW.Migrate.setup({
142
+ const migrate = await import_chunk_D6LYHB65.Migrate.setup({
143
143
  schemaEngineConfig: config,
144
144
  migrationsDirPath,
145
145
  schemaContext,
@@ -26,14 +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_I2VUHLTD_exports = {};
30
- __export(chunk_I2VUHLTD_exports, {
29
+ var chunk_6ORQRJLP_exports = {};
30
+ __export(chunk_6ORQRJLP_exports, {
31
31
  DbPull: () => DbPull
32
32
  });
33
- module.exports = __toCommonJS(chunk_I2VUHLTD_exports);
33
+ module.exports = __toCommonJS(chunk_6ORQRJLP_exports);
34
34
  var import_chunk_VU5BLQUI = require("./chunk-VU5BLQUI.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");
37
38
  var import_chunk_RTGQXNX6 = require("./chunk-RTGQXNX6.js");
38
39
  var import_chunk_JFKDSUIE = require("./chunk-JFKDSUIE.js");
39
40
  var import_chunk_AI6DH66U = require("./chunk-AI6DH66U.js");
@@ -41,7 +42,7 @@ var import_chunk_LGYRZ6CV = require("./chunk-LGYRZ6CV.js");
41
42
  var import_chunk_3WC4XD74 = require("./chunk-3WC4XD74.js");
42
43
  var import_chunk_2FXU5NZQ = require("./chunk-2FXU5NZQ.js");
43
44
  var import_chunk_74LUB4XX = require("./chunk-74LUB4XX.js");
44
- var import_chunk_RMMTCJSW = require("./chunk-RMMTCJSW.js");
45
+ var import_chunk_D6LYHB65 = require("./chunk-D6LYHB65.js");
45
46
  var import_chunk_AXR7LS2N = require("./chunk-AXR7LS2N.js");
46
47
  var import_chunk_SKRR5WT4 = require("./chunk-SKRR5WT4.js");
47
48
  var import_debug = __toESM(require("@prisma/debug"));
@@ -106,6 +107,7 @@ Set composite types introspection depth to 2 levels
106
107
  const args = (0, import_internals.arg)(argv, {
107
108
  "--help": Boolean,
108
109
  "-h": "--help",
110
+ "--url": String,
109
111
  "--print": Boolean,
110
112
  "--schema": String,
111
113
  "--config": String,
@@ -123,7 +125,8 @@ Set composite types introspection depth to 2 levels
123
125
  if (args["--help"]) {
124
126
  return this.help();
125
127
  }
126
- (0, import_internals.loadEnvFile)({ schemaPath: args["--schema"], printMessage: !args["--print"], config });
128
+ const url = args["--url"];
129
+ await (0, import_internals.loadEnvFile)({ schemaPath: args["--schema"], printMessage: !args["--print"], config });
127
130
  const schemaContext = await (0, import_internals.loadSchemaContext)({
128
131
  schemaPathFromArg: args["--schema"],
129
132
  schemaPathFromConfig: config.schema,
@@ -134,13 +137,14 @@ Set composite types introspection depth to 2 levels
134
137
  const cmd = "db pull";
135
138
  (0, import_internals.checkUnsupportedDataProxy)({
136
139
  cmd,
137
- schemaContext: schemaContext ?? void 0
140
+ schemaContext: schemaContext && !url ? schemaContext : void 0,
141
+ urls: [url]
138
142
  });
139
143
  (0, import_internals.checkUnsupportedSchemaEngineWasm)({
140
144
  cmd,
141
145
  config,
142
146
  args,
143
- flags: ["--local-d1"]
147
+ flags: ["--url", "--local-d1"]
144
148
  });
145
149
  const adapter = config.engine === "js" ? await config.adapter() : void 0;
146
150
  if (schemaContext && !args["--print"]) {
@@ -148,14 +152,30 @@ Set composite types introspection depth to 2 levels
148
152
  (0, import_chunk_2FXU5NZQ.printDatasource)({ datasourceInfo: (0, import_chunk_74LUB4XX.parseDatasourceInfo)(schemaContext?.primaryDatasource), adapter });
149
153
  }
150
154
  const fromD1 = Boolean(args["--local-d1"]);
151
- if (!schemaContext && !fromD1) {
155
+ if (!url && !schemaContext && !fromD1) {
152
156
  throw new import_chunk_3WC4XD74.NoSchemaFoundError();
153
157
  }
154
- const { firstDatasource, schema, validationWarning } = await (0, import_chunk_AXR7LS2N.z)({ schemaContext, fromD1 }).when(
158
+ const { firstDatasource, schema, validationWarning } = await (0, import_chunk_AXR7LS2N.z)({ url, schemaContext, fromD1 }).when(
155
159
  (input) => input.schemaContext !== null,
156
160
  async (input) => {
157
161
  const firstDatasource2 = input.schemaContext.primaryDatasource ? input.schemaContext.primaryDatasource : void 0;
158
- if (input.fromD1) {
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) {
159
179
  const d1Database = await (0, import_internals.locateLocalCloudflareD1)({ arg: "--from-local-d1" });
160
180
  const pathToSQLiteFile = import_path.default.relative(input.schemaContext.schemaRootDir, d1Database);
161
181
  const schema2 = [
@@ -190,6 +210,17 @@ ${this.urlToDatasource(`file:${pathToSQLiteFile}`, "sqlite")}`;
190
210
  });
191
211
  return { firstDatasource: config2.datasources[0], schema: schema2, validationWarning: void 0 };
192
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
+ }
193
224
  ).run();
194
225
  if (schemaContext) {
195
226
  const modelRegex = /\s*model\s*(\w+)\s*{/;
@@ -204,13 +235,13 @@ Some information will be lost (relations, comments, mapped fields, @ignore...),
204
235
  )} for more info.`);
205
236
  }
206
237
  }
207
- const migrate = await import_chunk_RMMTCJSW.Migrate.setup({
238
+ const migrate = await import_chunk_D6LYHB65.Migrate.setup({
208
239
  schemaEngineConfig: config,
209
240
  schemaContext: schemaContext ?? void 0,
210
241
  extensions: config["extensions"]
211
242
  });
212
243
  const engine = migrate.engine;
213
- const basedOn = schemaContext?.primaryDatasource ? ` based on datasource defined in ${(0, import_chunk_SKRR5WT4.underline)(schemaContext.loadedFromPathForLogMessages)}` : "";
244
+ const basedOn = !args["--url"] && schemaContext?.primaryDatasource ? ` based on datasource defined in ${(0, import_chunk_SKRR5WT4.underline)(schemaContext.loadedFromPathForLogMessages)}` : "";
214
245
  const introspectionSpinner = spinnerFactory(`Introspecting${basedOn}`);
215
246
  const before = Math.round(performance.now());
216
247
  let introspectionSchema = void 0;
@@ -247,7 +278,7 @@ ${(0, import_chunk_SKRR5WT4.bold)("To fix this, you have two options:")}
247
278
  "schema.prisma"
248
279
  )} points to a database that is not empty (it must contain at least one table).
249
280
 
250
- Then you can run ${(0, import_chunk_SKRR5WT4.green)((0, import_internals.getCommandWithExecutor)("prisma db pull"))} again.
281
+ Then you can run ${(0, import_chunk_SKRR5WT4.green)((0, import_internals.getCommandWithExecutor)("prisma db pull"))} again.
251
282
  `);
252
283
  } else if (e.code === "P1003") {
253
284
  throw new Error(`
@@ -266,7 +297,7 @@ ${(0, import_chunk_SKRR5WT4.bold)("To fix this, you have two options:")}
266
297
  "schema.prisma"
267
298
  )} points to an existing database.
268
299
 
269
- Then you can run ${(0, import_chunk_SKRR5WT4.green)((0, import_internals.getCommandWithExecutor)("prisma db pull"))} again.
300
+ Then you can run ${(0, import_chunk_SKRR5WT4.green)((0, import_internals.getCommandWithExecutor)("prisma db pull"))} again.
270
301
  `);
271
302
  } else if (e.code === "P1012") {
272
303
  process.stdout.write("\n");
@@ -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_RF72HHCJ_exports = {};
30
- __export(chunk_RF72HHCJ_exports, {
29
+ var chunk_7TVX3D4W_exports = {};
30
+ __export(chunk_7TVX3D4W_exports, {
31
31
  DbExecute: () => DbExecute
32
32
  });
33
- module.exports = __toCommonJS(chunk_RF72HHCJ_exports);
34
- var import_chunk_RMMTCJSW = require("./chunk-RMMTCJSW.js");
33
+ module.exports = __toCommonJS(chunk_7TVX3D4W_exports);
34
+ var import_chunk_D6LYHB65 = require("./chunk-D6LYHB65.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");
@@ -121,7 +121,7 @@ ${(0, import_chunk_SKRR5WT4.bold)("Examples")}
121
121
  if (args["--help"]) {
122
122
  return this.help();
123
123
  }
124
- (0, import_internals.loadEnvFile)({ schemaPath: args["--schema"], printMessage: false, config });
124
+ await (0, import_internals.loadEnvFile)({ schemaPath: args["--schema"], printMessage: false, config });
125
125
  const cmd = "db execute";
126
126
  (0, import_internals.checkUnsupportedSchemaEngineWasm)({
127
127
  cmd,
@@ -188,7 +188,7 @@ See \`${(0, import_chunk_SKRR5WT4.green)((0, import_internals.getCommandWithExec
188
188
  configDir: schemaContext.primaryDatasourceDirectory
189
189
  };
190
190
  }
191
- const migrate = await import_chunk_RMMTCJSW.Migrate.setup({ schemaEngineConfig: config, extensions: config["extensions"] });
191
+ const migrate = await import_chunk_D6LYHB65.Migrate.setup({ schemaEngineConfig: config, extensions: config["extensions"] });
192
192
  try {
193
193
  await migrate.engine.dbExecute({
194
194
  script,
@@ -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_TVLHBYPV_exports = {};
30
- __export(chunk_TVLHBYPV_exports, {
29
+ var chunk_BHJMJSM4_exports = {};
30
+ __export(chunk_BHJMJSM4_exports, {
31
31
  MigrateDeploy: () => MigrateDeploy
32
32
  });
33
- module.exports = __toCommonJS(chunk_TVLHBYPV_exports);
33
+ module.exports = __toCommonJS(chunk_BHJMJSM4_exports);
34
34
  var import_chunk_KRQEFTDT = require("./chunk-KRQEFTDT.js");
35
35
  var import_chunk_2FXU5NZQ = require("./chunk-2FXU5NZQ.js");
36
36
  var import_chunk_74LUB4XX = require("./chunk-74LUB4XX.js");
37
- var import_chunk_RMMTCJSW = require("./chunk-RMMTCJSW.js");
37
+ var import_chunk_D6LYHB65 = require("./chunk-D6LYHB65.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");
@@ -83,7 +83,7 @@ ${(0, import_chunk_SKRR5WT4.bold)("Examples")}
83
83
  if (args["--help"]) {
84
84
  return this.help();
85
85
  }
86
- (0, import_internals.loadEnvFile)({ schemaPath: args["--schema"], printMessage: true, config });
86
+ await (0, import_internals.loadEnvFile)({ schemaPath: args["--schema"], printMessage: true, config });
87
87
  const schemaContext = await (0, import_internals.loadSchemaContext)({
88
88
  schemaPathFromArg: args["--schema"],
89
89
  schemaPathFromConfig: config.schema,
@@ -97,7 +97,7 @@ ${(0, import_chunk_SKRR5WT4.bold)("Examples")}
97
97
  externalTables: config.tables?.external ?? [],
98
98
  externalEnums: config.enums?.external ?? []
99
99
  };
100
- const migrate = await import_chunk_RMMTCJSW.Migrate.setup({
100
+ const migrate = await import_chunk_D6LYHB65.Migrate.setup({
101
101
  schemaEngineConfig: config,
102
102
  migrationsDirPath,
103
103
  schemaContext,
@@ -16,12 +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_W2NKGYXF_exports = {};
20
- __export(chunk_W2NKGYXF_exports, {
19
+ var chunk_D4TRX77Y_exports = {};
20
+ __export(chunk_D4TRX77Y_exports, {
21
21
  DbSeed: () => DbSeed
22
22
  });
23
- module.exports = __toCommonJS(chunk_W2NKGYXF_exports);
24
- var import_chunk_L7EZFBB4 = require("./chunk-L7EZFBB4.js");
23
+ module.exports = __toCommonJS(chunk_D4TRX77Y_exports);
24
+ var import_chunk_PHXLQVPT = require("./chunk-PHXLQVPT.js");
25
25
  var import_chunk_SKRR5WT4 = require("./chunk-SKRR5WT4.js");
26
26
  var import_chunk_2ESYSVXG = require("./chunk-2ESYSVXG.js");
27
27
  var import_internals = require("@prisma/internals");
@@ -213,11 +213,13 @@ ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma db seed -- --arg1 value1 --arg2 va
213
213
  if (args["--help"]) {
214
214
  return this.help();
215
215
  }
216
- (0, import_internals.loadEnvFile)({ schemaPath: args["--schema"], printMessage: true, config });
217
- const seedCommand = config.migrations?.seed;
216
+ await (0, import_internals.loadEnvFile)({ schemaPath: args["--schema"], printMessage: true, config });
217
+ const seedCommandFromPrismaConfig = config.migrations?.seed;
218
+ const seedCommandFromPkgJson = await (0, import_chunk_PHXLQVPT.getSeedCommandFromPackageJson)(process.cwd());
219
+ const seedCommand = seedCommandFromPrismaConfig ?? seedCommandFromPkgJson;
218
220
  if (!seedCommand) return ``;
219
221
  const extraArgs = args._.join(" ");
220
- const successfulSeeding = await (0, import_chunk_L7EZFBB4.executeSeedCommand)({ commandFromConfig: seedCommand, extraArgs });
222
+ const successfulSeeding = await (0, import_chunk_PHXLQVPT.executeSeedCommand)({ commandFromConfig: seedCommand, extraArgs });
221
223
  if (successfulSeeding) {
222
224
  return `
223
225
  ${process.platform === "win32" ? "" : "\u{1F331} "}The seed command has been executed.`;
@@ -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_RMMTCJSW_exports = {};
30
- __export(chunk_RMMTCJSW_exports, {
29
+ var chunk_D6LYHB65_exports = {};
30
+ __export(chunk_D6LYHB65_exports, {
31
31
  Migrate: () => Migrate
32
32
  });
33
- module.exports = __toCommonJS(chunk_RMMTCJSW_exports);
34
- var import_chunk_VV4M6AN7 = require("./chunk-VV4M6AN7.js");
33
+ module.exports = __toCommonJS(chunk_D6LYHB65_exports);
35
34
  var import_chunk_T64SUJ5L = require("./chunk-T64SUJ5L.js");
35
+ var import_chunk_VV4M6AN7 = require("./chunk-VV4M6AN7.js");
36
36
  var import_chunk_GGA2F64G = require("./chunk-GGA2F64G.js");
37
37
  var import_chunk_23DZXSTI = require("./chunk-23DZXSTI.js");
38
38
  var import_chunk_22YP3RXZ = require("./chunk-22YP3RXZ.js");
@@ -26,11 +26,11 @@ 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_F4ENFSD2_exports = {};
30
- __export(chunk_F4ENFSD2_exports, {
29
+ var chunk_F2XCBEZ4_exports = {};
30
+ __export(chunk_F2XCBEZ4_exports, {
31
31
  MigrateDev: () => MigrateDev
32
32
  });
33
- module.exports = __toCommonJS(chunk_F4ENFSD2_exports);
33
+ module.exports = __toCommonJS(chunk_F2XCBEZ4_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");
@@ -38,8 +38,8 @@ 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
40
  var import_chunk_74LUB4XX = require("./chunk-74LUB4XX.js");
41
- var import_chunk_L7EZFBB4 = require("./chunk-L7EZFBB4.js");
42
- var import_chunk_RMMTCJSW = require("./chunk-RMMTCJSW.js");
41
+ var import_chunk_PHXLQVPT = require("./chunk-PHXLQVPT.js");
42
+ var import_chunk_D6LYHB65 = require("./chunk-D6LYHB65.js");
43
43
  var import_chunk_SKRR5WT4 = require("./chunk-SKRR5WT4.js");
44
44
  var import_node_path = __toESM(require("node:path"));
45
45
  var import_debug = __toESM(require("@prisma/debug"));
@@ -100,7 +100,7 @@ ${(0, import_chunk_SKRR5WT4.bold)("Examples")}
100
100
  if (args["--help"]) {
101
101
  return this.help();
102
102
  }
103
- (0, import_internals.loadEnvFile)({ schemaPath: args["--schema"], printMessage: true, config });
103
+ await (0, import_internals.loadEnvFile)({ schemaPath: args["--schema"], printMessage: true, config });
104
104
  const schemaContext = await (0, import_internals.loadSchemaContext)({
105
105
  schemaPathFromArg: args["--schema"],
106
106
  schemaPathFromConfig: config.schema,
@@ -124,7 +124,7 @@ ${(0, import_chunk_SKRR5WT4.bold)("Examples")}
124
124
  externalTables: config.tables?.external ?? [],
125
125
  externalEnums: config.enums?.external ?? []
126
126
  };
127
- const migrate = await import_chunk_RMMTCJSW.Migrate.setup({
127
+ const migrate = await import_chunk_D6LYHB65.Migrate.setup({
128
128
  schemaEngineConfig: config,
129
129
  migrationsDirPath,
130
130
  schemaContext,
@@ -286,10 +286,12 @@ ${(0, import_chunk_SKRR5WT4.green)("Your database is now in sync with your schem
286
286
  }
287
287
  if (wasDbCreated && !process.env.PRISMA_MIGRATE_SKIP_SEED && !args["--skip-seed"]) {
288
288
  try {
289
- const seedCommand = config.migrations?.seed;
289
+ const seedCommandFromPrismaConfig = config.migrations?.seed;
290
+ const seedCommandFromPkgJson = await (0, import_chunk_PHXLQVPT.getSeedCommandFromPackageJson)(process.cwd());
291
+ const seedCommand = seedCommandFromPrismaConfig ?? seedCommandFromPkgJson;
290
292
  if (seedCommand) {
291
293
  process.stdout.write("\n");
292
- const successfulSeeding = await (0, import_chunk_L7EZFBB4.executeSeedCommand)({ commandFromConfig: seedCommand });
294
+ const successfulSeeding = await (0, import_chunk_PHXLQVPT.executeSeedCommand)({ commandFromConfig: seedCommand });
293
295
  if (successfulSeeding) {
294
296
  process.stdout.write(`
295
297
  ${process.platform === "win32" ? "" : "\u{1F331} "}The seed command has been executed.
@@ -26,18 +26,18 @@ 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_NX7CVZ33_exports = {};
30
- __export(chunk_NX7CVZ33_exports, {
29
+ var chunk_J33EXHZB_exports = {};
30
+ __export(chunk_J33EXHZB_exports, {
31
31
  MigrateReset: () => MigrateReset
32
32
  });
33
- module.exports = __toCommonJS(chunk_NX7CVZ33_exports);
33
+ module.exports = __toCommonJS(chunk_J33EXHZB_exports);
34
34
  var import_chunk_KRQEFTDT = require("./chunk-KRQEFTDT.js");
35
35
  var import_chunk_FBDQVK4W = require("./chunk-FBDQVK4W.js");
36
36
  var import_chunk_3WC4XD74 = require("./chunk-3WC4XD74.js");
37
37
  var import_chunk_2FXU5NZQ = require("./chunk-2FXU5NZQ.js");
38
38
  var import_chunk_74LUB4XX = require("./chunk-74LUB4XX.js");
39
- var import_chunk_L7EZFBB4 = require("./chunk-L7EZFBB4.js");
40
- var import_chunk_RMMTCJSW = require("./chunk-RMMTCJSW.js");
39
+ var import_chunk_PHXLQVPT = require("./chunk-PHXLQVPT.js");
40
+ var import_chunk_D6LYHB65 = require("./chunk-D6LYHB65.js");
41
41
  var import_chunk_SKRR5WT4 = require("./chunk-SKRR5WT4.js");
42
42
  var import_internals = require("@prisma/internals");
43
43
  var import_prompts = __toESM(require("prompts"));
@@ -90,7 +90,7 @@ ${(0, import_chunk_SKRR5WT4.bold)("Examples")}
90
90
  if (args["--help"]) {
91
91
  return this.help();
92
92
  }
93
- (0, import_internals.loadEnvFile)({ schemaPath: args["--schema"], printMessage: true, config });
93
+ await (0, import_internals.loadEnvFile)({ schemaPath: args["--schema"], printMessage: true, config });
94
94
  const schemaContext = await (0, import_internals.loadSchemaContext)({
95
95
  schemaPathFromArg: args["--schema"],
96
96
  schemaPathFromConfig: config.schema,
@@ -128,7 +128,7 @@ ${(0, import_chunk_SKRR5WT4.bold)("Examples")}
128
128
  externalTables: config.tables?.external ?? [],
129
129
  externalEnums: config.enums?.external ?? []
130
130
  };
131
- const migrate = await import_chunk_RMMTCJSW.Migrate.setup({
131
+ const migrate = await import_chunk_D6LYHB65.Migrate.setup({
132
132
  schemaEngineConfig: config,
133
133
  migrationsDirPath,
134
134
  schemaContext,
@@ -163,10 +163,12 @@ ${(0, import_chunk_KRQEFTDT.printFilesFromMigrationIds)("migrations", migrationI
163
163
  await migrate.tryToRunGenerate(datasourceInfo);
164
164
  }
165
165
  if (!process.env.PRISMA_MIGRATE_SKIP_SEED && !args["--skip-seed"]) {
166
- const seedCommand = config.migrations?.seed;
166
+ const seedCommandFromPrismaConfig = config.migrations?.seed;
167
+ const seedCommandFromPkgJson = await (0, import_chunk_PHXLQVPT.getSeedCommandFromPackageJson)(process.cwd());
168
+ const seedCommand = seedCommandFromPrismaConfig ?? seedCommandFromPkgJson;
167
169
  if (seedCommand) {
168
170
  process.stdout.write("\n");
169
- const successfulSeeding = await (0, import_chunk_L7EZFBB4.executeSeedCommand)({ commandFromConfig: seedCommand });
171
+ const successfulSeeding = await (0, import_chunk_PHXLQVPT.executeSeedCommand)({ commandFromConfig: seedCommand });
170
172
  if (successfulSeeding) {
171
173
  process.stdout.write(`
172
174
  ${process.platform === "win32" ? "" : "\u{1F331} "}The seed command has been executed.
@@ -26,19 +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_ZBQSD3YW_exports = {};
30
- __export(chunk_ZBQSD3YW_exports, {
29
+ var chunk_NB4FRYRQ_exports = {};
30
+ __export(chunk_NB4FRYRQ_exports, {
31
31
  getDatabaseVersionSafe: () => getDatabaseVersionSafe
32
32
  });
33
- module.exports = __toCommonJS(chunk_ZBQSD3YW_exports);
34
- var import_chunk_RMMTCJSW = require("./chunk-RMMTCJSW.js");
33
+ module.exports = __toCommonJS(chunk_NB4FRYRQ_exports);
34
+ var import_chunk_D6LYHB65 = require("./chunk-D6LYHB65.js");
35
35
  var import_debug = __toESM(require("@prisma/debug"));
36
36
  var debug = (0, import_debug.default)("prisma:cli");
37
37
  async function getDatabaseVersionSafe(args) {
38
38
  let migrate;
39
39
  let dbVersion;
40
40
  try {
41
- migrate = await import_chunk_RMMTCJSW.Migrate.setup({});
41
+ migrate = await import_chunk_D6LYHB65.Migrate.setup({});
42
42
  dbVersion = await migrate.engine.getDatabaseVersion(args);
43
43
  } catch (e) {
44
44
  debug(e);
@@ -16,12 +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_EDBWBKKM_exports = {};
20
- __export(chunk_EDBWBKKM_exports, {
19
+ var chunk_O35BTK6Y_exports = {};
20
+ __export(chunk_O35BTK6Y_exports, {
21
21
  introspectSql: () => introspectSql
22
22
  });
23
- module.exports = __toCommonJS(chunk_EDBWBKKM_exports);
24
- var import_chunk_RMMTCJSW = require("./chunk-RMMTCJSW.js");
23
+ module.exports = __toCommonJS(chunk_O35BTK6Y_exports);
24
+ var import_chunk_D6LYHB65 = require("./chunk-D6LYHB65.js");
25
25
  var import_internals = require("@prisma/internals");
26
26
  var supportedProviders = ["postgresql", "cockroachdb", "mysql", "sqlite"];
27
27
  async function introspectSql(schemaContext, queries) {
@@ -41,7 +41,7 @@ async function introspectSql(schemaContext, queries) {
41
41
  `Could not get url from datasource ${firstDatasource.name} in ${schemaContext.loadedFromPathForLogMessages}`
42
42
  );
43
43
  }
44
- const migrate = await import_chunk_RMMTCJSW.Migrate.setup({ schemaContext });
44
+ const migrate = await import_chunk_D6LYHB65.Migrate.setup({ schemaContext });
45
45
  const schemaEngine = migrate.engine;
46
46
  const results = [];
47
47
  const errors = [];