@prisma/migrate 6.19.0-integration-next.16 → 6.19.0-integration-engines-6-19-0-32-next-568b222d0ab829bbbe5f2fd48ed587836813346c.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 (42) hide show
  1. package/dist/Migrate.js +3 -3
  2. package/dist/bin.js +27 -26
  3. package/dist/{chunk-25AB2KOW.js → chunk-3AKRTEIK.js} +11 -10
  4. package/dist/{chunk-GIFCHCJW.js → chunk-6ORQRJLP.js} +51 -16
  5. package/dist/{chunk-AP47ZTTC.js → chunk-7TVX3D4W.js} +65 -27
  6. package/dist/{chunk-7WBJ2X2Q.js → chunk-BHJMJSM4.js} +7 -6
  7. package/dist/{chunk-WF7UXKO5.js → chunk-D4TRX77Y.js} +9 -6
  8. package/dist/{chunk-MOFG2YPJ.js → chunk-D6LYHB65.js} +7 -5
  9. package/dist/{chunk-CC6YNI65.js → chunk-F2XCBEZ4.js} +13 -10
  10. package/dist/{chunk-L2HDMVMA.js → chunk-J33EXHZB.js} +12 -9
  11. package/dist/{chunk-SIUB4YHK.js → chunk-NB4FRYRQ.js} +5 -5
  12. package/dist/{chunk-ZRKC6FIA.js → chunk-O35BTK6Y.js} +13 -9
  13. package/dist/{chunk-L7EZFBB4.js → chunk-PHXLQVPT.js} +68 -40
  14. package/dist/{chunk-IABFQ4QV.js → chunk-R4IWP35Z.js} +9 -8
  15. package/dist/chunk-RR6BKMNO.js +80 -0
  16. package/dist/{chunk-3UZC7DDN.js → chunk-TW22Y3AA.js} +7 -6
  17. package/dist/{chunk-GY34KW2I.js → chunk-Z27SI4AV.js} +4 -6
  18. package/dist/{chunk-LV343IWU.js → chunk-ZTIS675B.js} +48 -11
  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/Migrate.d.ts +2 -1
  33. package/dist/migrate/src/utils/introspectSql.d.ts +1 -2
  34. package/dist/migrate/src/utils/replaceOrAddDatasource.d.ts +2 -0
  35. package/dist/migrate/src/utils/replaceOrAddDatasource.test.d.ts +1 -0
  36. package/dist/migrate/src/utils/seed.d.ts +6 -0
  37. package/dist/utils/getDatabaseVersionSafe.js +4 -4
  38. package/dist/utils/introspectSql.js +4 -4
  39. package/dist/utils/replaceOrAddDatasource.js +25 -0
  40. package/dist/utils/replaceOrAddDatasource.test.js +207 -0
  41. package/dist/utils/seed.js +3 -2
  42. 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_MOFG2YPJ.Migrate
21
+ Migrate: () => import_chunk_D6LYHB65.Migrate
22
22
  });
23
23
  module.exports = __toCommonJS(Migrate_exports);
24
- var import_chunk_MOFG2YPJ = require("./chunk-MOFG2YPJ.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_SIUB4YHK = require("./chunk-SIUB4YHK.js");
27
- var import_chunk_7WBJ2X2Q = require("./chunk-7WBJ2X2Q.js");
28
- var import_chunk_CC6YNI65 = require("./chunk-CC6YNI65.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_LV343IWU = require("./chunk-LV343IWU.js");
31
+ var import_chunk_ZTIS675B = require("./chunk-ZTIS675B.js");
32
32
  var import_chunk_VAJ4VX67 = require("./chunk-VAJ4VX67.js");
33
- var import_chunk_L2HDMVMA = require("./chunk-L2HDMVMA.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_25AB2KOW = require("./chunk-25AB2KOW.js");
37
- var import_chunk_IABFQ4QV = require("./chunk-IABFQ4QV.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_AP47ZTTC = require("./chunk-AP47ZTTC.js");
40
- var import_chunk_GIFCHCJW = require("./chunk-GIFCHCJW.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_3UZC7DDN = require("./chunk-3UZC7DDN.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_WF7UXKO5 = require("./chunk-WF7UXKO5.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_MOFG2YPJ = require("./chunk-MOFG2YPJ.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.16";
75
+ var version = "6.19.0-integration-engines-6-19-0-32-next-568b222d0ab829bbbe5f2fd48ed587836813346c.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_CC6YNI65.MigrateDev.new(),
97
- status: import_chunk_IABFQ4QV.MigrateStatus.new(),
98
- resolve: import_chunk_25AB2KOW.MigrateResolve.new(),
99
- reset: import_chunk_L2HDMVMA.MigrateReset.new(),
100
- deploy: import_chunk_7WBJ2X2Q.MigrateDeploy.new(),
101
- diff: import_chunk_LV343IWU.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_AP47ZTTC.DbExecute.new(),
105
- pull: import_chunk_GIFCHCJW.DbPull.new(),
106
- push: import_chunk_3UZC7DDN.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_WF7UXKO5.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_SIUB4YHK.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_25AB2KOW_exports = {};
20
- __export(chunk_25AB2KOW_exports, {
19
+ var chunk_3AKRTEIK_exports = {};
20
+ __export(chunk_3AKRTEIK_exports, {
21
21
  MigrateResolve: () => MigrateResolve
22
22
  });
23
- module.exports = __toCommonJS(chunk_25AB2KOW_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_MOFG2YPJ = require("./chunk-MOFG2YPJ.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 {
@@ -31,7 +31,7 @@ var MigrateResolve = class _MigrateResolve {
31
31
  return new _MigrateResolve();
32
32
  }
33
33
  static help = (0, import_internals.format)(`
34
- Resolve issues with database migrations in deployment databases:
34
+ Resolve issues with database migrations in deployment databases:
35
35
  - recover from failed migrations
36
36
  - baseline databases when starting to use Prisma Migrate on existing databases
37
37
  - reconcile hotfixes done manually on databases with your migration history
@@ -39,11 +39,11 @@ Resolve issues with database migrations in deployment databases:
39
39
  Run "prisma migrate status" to identify if you need to use resolve.
40
40
 
41
41
  Read more about resolving migration history issues: ${(0, import_internals.link)("https://pris.ly/d/migrate-resolve")}
42
-
42
+
43
43
  ${(0, import_chunk_SKRR5WT4.bold)("Usage")}
44
44
 
45
45
  ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma migrate resolve [options]
46
-
46
+
47
47
  ${(0, import_chunk_SKRR5WT4.bold)("Options")}
48
48
 
49
49
  -h, --help Display this help message
@@ -54,7 +54,7 @@ ${(0, import_chunk_SKRR5WT4.bold)("Options")}
54
54
 
55
55
  ${(0, import_chunk_SKRR5WT4.bold)("Examples")}
56
56
 
57
- Update migrations table, recording a specific migration as applied
57
+ Update migrations table, recording a specific migration as applied
58
58
  ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma migrate resolve --applied 20201231000000_add_users_table
59
59
 
60
60
  Update migrations table, recording a specific migration as rolled back
@@ -83,6 +83,7 @@ ${(0, import_chunk_SKRR5WT4.bold)("Examples")}
83
83
  if (args["--help"]) {
84
84
  return this.help();
85
85
  }
86
+ await (0, import_internals.loadEnvFile)({ schemaPath: args["--schema"], printMessage: true, config });
86
87
  const schemaContext = await (0, import_internals.loadSchemaContext)({
87
88
  schemaPathFromArg: args["--schema"],
88
89
  schemaPathFromConfig: config.schema,
@@ -112,7 +113,7 @@ ${(0, import_chunk_SKRR5WT4.bold)((0, import_chunk_SKRR5WT4.green)((0, import_in
112
113
  if (!adapter) {
113
114
  await (0, import_chunk_74LUB4XX.ensureCanConnectToDatabase)(schemaContext.primaryDatasource);
114
115
  }
115
- const migrate = await import_chunk_MOFG2YPJ.Migrate.setup({
116
+ const migrate = await import_chunk_D6LYHB65.Migrate.setup({
116
117
  schemaEngineConfig: config,
117
118
  migrationsDirPath,
118
119
  schemaContext,
@@ -138,7 +139,7 @@ Migration ${args["--applied"]} marked as applied.
138
139
  );
139
140
  }
140
141
  await (0, import_chunk_74LUB4XX.ensureCanConnectToDatabase)(schemaContext.primaryDatasource);
141
- const migrate = await import_chunk_MOFG2YPJ.Migrate.setup({
142
+ const migrate = await import_chunk_D6LYHB65.Migrate.setup({
142
143
  schemaEngineConfig: config,
143
144
  migrationsDirPath,
144
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_GIFCHCJW_exports = {};
30
- __export(chunk_GIFCHCJW_exports, {
29
+ var chunk_6ORQRJLP_exports = {};
30
+ __export(chunk_6ORQRJLP_exports, {
31
31
  DbPull: () => DbPull
32
32
  });
33
- module.exports = __toCommonJS(chunk_GIFCHCJW_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_MOFG2YPJ = require("./chunk-MOFG2YPJ.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,6 +125,8 @@ Set composite types introspection depth to 2 levels
123
125
  if (args["--help"]) {
124
126
  return this.help();
125
127
  }
128
+ const url = args["--url"];
129
+ await (0, import_internals.loadEnvFile)({ schemaPath: args["--schema"], printMessage: !args["--print"], config });
126
130
  const schemaContext = await (0, import_internals.loadSchemaContext)({
127
131
  schemaPathFromArg: args["--schema"],
128
132
  schemaPathFromConfig: config.schema,
@@ -133,13 +137,14 @@ Set composite types introspection depth to 2 levels
133
137
  const cmd = "db pull";
134
138
  (0, import_internals.checkUnsupportedDataProxy)({
135
139
  cmd,
136
- schemaContext: schemaContext ?? void 0
140
+ schemaContext: schemaContext && !url ? schemaContext : void 0,
141
+ urls: [url]
137
142
  });
138
143
  (0, import_internals.checkUnsupportedSchemaEngineWasm)({
139
144
  cmd,
140
145
  config,
141
146
  args,
142
- flags: ["--local-d1"]
147
+ flags: ["--url", "--local-d1"]
143
148
  });
144
149
  const adapter = config.engine === "js" ? await config.adapter() : void 0;
145
150
  if (schemaContext && !args["--print"]) {
@@ -147,26 +152,44 @@ Set composite types introspection depth to 2 levels
147
152
  (0, import_chunk_2FXU5NZQ.printDatasource)({ datasourceInfo: (0, import_chunk_74LUB4XX.parseDatasourceInfo)(schemaContext?.primaryDatasource), adapter });
148
153
  }
149
154
  const fromD1 = Boolean(args["--local-d1"]);
150
- if (!schemaContext && !fromD1) {
155
+ if (!url && !schemaContext && !fromD1) {
151
156
  throw new import_chunk_3WC4XD74.NoSchemaFoundError();
152
157
  }
153
- 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(
154
159
  (input) => input.schemaContext !== null,
155
160
  async (input) => {
156
161
  const firstDatasource2 = input.schemaContext.primaryDatasource ? input.schemaContext.primaryDatasource : void 0;
157
- 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) {
158
179
  const d1Database = await (0, import_internals.locateLocalCloudflareD1)({ arg: "--from-local-d1" });
159
180
  const pathToSQLiteFile = import_path.default.relative(input.schemaContext.schemaRootDir, d1Database);
160
181
  const schema2 = [
161
182
  ["schema.prisma", this.urlToDatasource(`file:${pathToSQLiteFile}`, "sqlite")]
162
183
  ];
163
184
  const config2 = await (0, import_internals.getConfig)({
164
- datamodel: schema2
185
+ datamodel: schema2,
186
+ ignoreEnvVarErrors: true
165
187
  });
166
188
  return { firstDatasource: config2.datasources[0], schema: schema2, validationWarning: void 0 };
167
189
  } else {
168
190
  await (0, import_internals.getConfig)({
169
- datamodel: input.schemaContext.schemaFiles
191
+ datamodel: input.schemaContext.schemaFiles,
192
+ ignoreEnvVarErrors: false
170
193
  });
171
194
  }
172
195
  return { firstDatasource: firstDatasource2, schema: input.schemaContext.schemaFiles, validationWarning: void 0 };
@@ -182,7 +205,19 @@ Set composite types introspection depth to 2 levels
182
205
  ${this.urlToDatasource(`file:${pathToSQLiteFile}`, "sqlite")}`;
183
206
  const schema2 = [["schema.prisma", schemaContent]];
184
207
  const config2 = await (0, import_internals.getConfig)({
185
- datamodel: schema2
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
186
221
  });
187
222
  return { firstDatasource: config2.datasources[0], schema: schema2, validationWarning: void 0 };
188
223
  }
@@ -200,13 +235,13 @@ Some information will be lost (relations, comments, mapped fields, @ignore...),
200
235
  )} for more info.`);
201
236
  }
202
237
  }
203
- const migrate = await import_chunk_MOFG2YPJ.Migrate.setup({
238
+ const migrate = await import_chunk_D6LYHB65.Migrate.setup({
204
239
  schemaEngineConfig: config,
205
240
  schemaContext: schemaContext ?? void 0,
206
241
  extensions: config["extensions"]
207
242
  });
208
243
  const engine = migrate.engine;
209
- 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)}` : "";
210
245
  const introspectionSpinner = spinnerFactory(`Introspecting${basedOn}`);
211
246
  const before = Math.round(performance.now());
212
247
  let introspectionSchema = void 0;
@@ -243,7 +278,7 @@ ${(0, import_chunk_SKRR5WT4.bold)("To fix this, you have two options:")}
243
278
  "schema.prisma"
244
279
  )} points to a database that is not empty (it must contain at least one table).
245
280
 
246
- 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.
247
282
  `);
248
283
  } else if (e.code === "P1003") {
249
284
  throw new Error(`
@@ -262,7 +297,7 @@ ${(0, import_chunk_SKRR5WT4.bold)("To fix this, you have two options:")}
262
297
  "schema.prisma"
263
298
  )} points to an existing database.
264
299
 
265
- 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.
266
301
  `);
267
302
  } else if (e.code === "P1012") {
268
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_AP47ZTTC_exports = {};
30
- __export(chunk_AP47ZTTC_exports, {
29
+ var chunk_7TVX3D4W_exports = {};
30
+ __export(chunk_7TVX3D4W_exports, {
31
31
  DbExecute: () => DbExecute
32
32
  });
33
- module.exports = __toCommonJS(chunk_AP47ZTTC_exports);
34
- var import_chunk_MOFG2YPJ = require("./chunk-MOFG2YPJ.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");
@@ -47,7 +47,9 @@ ${(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
- Datasource configuration is read from ${(0, import_chunk_SKRR5WT4.italic)("prisma.config.ts")}.
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
51
53
 
52
54
  ${(0, import_chunk_SKRR5WT4.italic)("Script input, only 1 must be provided:")}
53
55
  --file Path to a file. The content will be sent as the script to be executed
@@ -66,11 +68,11 @@ var DbExecute = class _DbExecute {
66
68
  static help = (0, import_internals.format)(`
67
69
  ${process.platform === "win32" ? "" : "\u{1F4DD} "}Execute native commands to your database
68
70
 
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)(
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)(
70
72
  `--stdin`
71
73
  )} or ${(0, import_chunk_SKRR5WT4.green)(`--file`)}.
72
- The script input parameters are mutually exclusive, only 1 must be provided.
73
-
74
+ The input parameters are mutually exclusive, only 1 of each (datasource & script) must be provided.
75
+
74
76
  The output of the command is connector-specific, and is not meant for returning data, but only to report success or failure.
75
77
 
76
78
  On SQL databases, this command takes as input a SQL script.
@@ -80,14 +82,23 @@ ${(0, import_chunk_SKRR5WT4.italic)(`This command is currently not supported on
80
82
 
81
83
  ${helpOptions}
82
84
  ${(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
83
90
 
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
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"
86
96
 
87
- Execute the SQL script from stdin using the configured datasource
97
+ Like previous example, but exposing the datasource url credentials to your terminal history
88
98
  ${(0, import_chunk_SKRR5WT4.dim)("$")} echo 'TRUNCATE TABLE dev;' | \\
89
99
  prisma db execute \\
90
- --stdin
100
+ --stdin \\
101
+ --url="mysql://root:root@localhost/mydb"
91
102
  `);
92
103
  async parse(argv, config) {
93
104
  const args = (0, import_internals.arg)(
@@ -98,6 +109,8 @@ ${(0, import_chunk_SKRR5WT4.bold)("Examples")}
98
109
  "--config": String,
99
110
  "--stdin": Boolean,
100
111
  "--file": String,
112
+ "--schema": String,
113
+ "--url": String,
101
114
  "--telemetry-information": String
102
115
  },
103
116
  false
@@ -108,15 +121,33 @@ ${(0, import_chunk_SKRR5WT4.bold)("Examples")}
108
121
  if (args["--help"]) {
109
122
  return this.help();
110
123
  }
124
+ await (0, import_internals.loadEnvFile)({ schemaPath: args["--schema"], printMessage: false, config });
111
125
  const cmd = "db execute";
126
+ (0, import_internals.checkUnsupportedSchemaEngineWasm)({
127
+ cmd,
128
+ config,
129
+ args,
130
+ flags: ["--url"]
131
+ });
112
132
  if (args["--stdin"] && args["--file"]) {
113
133
  throw new Error(
114
- `--stdin and --file cannot be used at the same time. Only 1 must be provided.
134
+ `--stdin and --file cannot be used at the same time. Only 1 must be provided.
115
135
  See \`${(0, import_chunk_SKRR5WT4.green)((0, import_internals.getCommandWithExecutor)("prisma db execute -h"))}\``
116
136
  );
117
137
  } else if (!args["--stdin"] && !args["--file"]) {
118
138
  throw new Error(
119
139
  `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.
120
151
  See \`${(0, import_chunk_SKRR5WT4.green)((0, import_internals.getCommandWithExecutor)("prisma db execute -h"))}\``
121
152
  );
122
153
  }
@@ -136,21 +167,28 @@ See \`${(0, import_chunk_SKRR5WT4.green)((0, import_internals.getCommandWithExec
136
167
  if (args["--stdin"]) {
137
168
  script = await import_consumers.default.text(process.stdin);
138
169
  }
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
- );
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
+ };
147
190
  }
148
- (0, import_internals.checkUnsupportedDataProxy)({ cmd, urls: [config.datasource.url] });
149
- const datasourceType = {
150
- tag: "url",
151
- url: config.datasource.url
152
- };
153
- const migrate = await import_chunk_MOFG2YPJ.Migrate.setup({ schemaEngineConfig: config, extensions: config["extensions"] });
191
+ const migrate = await import_chunk_D6LYHB65.Migrate.setup({ schemaEngineConfig: config, extensions: config["extensions"] });
154
192
  try {
155
193
  await migrate.engine.dbExecute({
156
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_7WBJ2X2Q_exports = {};
30
- __export(chunk_7WBJ2X2Q_exports, {
29
+ var chunk_BHJMJSM4_exports = {};
30
+ __export(chunk_BHJMJSM4_exports, {
31
31
  MigrateDeploy: () => MigrateDeploy
32
32
  });
33
- module.exports = __toCommonJS(chunk_7WBJ2X2Q_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_MOFG2YPJ = require("./chunk-MOFG2YPJ.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,6 +83,7 @@ ${(0, import_chunk_SKRR5WT4.bold)("Examples")}
83
83
  if (args["--help"]) {
84
84
  return this.help();
85
85
  }
86
+ await (0, import_internals.loadEnvFile)({ schemaPath: args["--schema"], printMessage: true, config });
86
87
  const schemaContext = await (0, import_internals.loadSchemaContext)({
87
88
  schemaPathFromArg: args["--schema"],
88
89
  schemaPathFromConfig: config.schema,
@@ -96,7 +97,7 @@ ${(0, import_chunk_SKRR5WT4.bold)("Examples")}
96
97
  externalTables: config.tables?.external ?? [],
97
98
  externalEnums: config.enums?.external ?? []
98
99
  };
99
- const migrate = await import_chunk_MOFG2YPJ.Migrate.setup({
100
+ const migrate = await import_chunk_D6LYHB65.Migrate.setup({
100
101
  schemaEngineConfig: config,
101
102
  migrationsDirPath,
102
103
  schemaContext,
@@ -148,7 +149,7 @@ ${(0, import_chunk_KRQEFTDT.printFilesFromMigrationIds)(
148
149
  "migration.sql": ""
149
150
  }
150
151
  )}
151
-
152
+
152
153
  ${(0, import_chunk_SKRR5WT4.green)("All migrations have been successfully applied.")}`;
153
154
  }
154
155
  }
@@ -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_WF7UXKO5_exports = {};
20
- __export(chunk_WF7UXKO5_exports, {
19
+ var chunk_D4TRX77Y_exports = {};
20
+ __export(chunk_D4TRX77Y_exports, {
21
21
  DbSeed: () => DbSeed
22
22
  });
23
- module.exports = __toCommonJS(chunk_WF7UXKO5_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,10 +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
- 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;
217
220
  if (!seedCommand) return ``;
218
221
  const extraArgs = args._.join(" ");
219
- const successfulSeeding = await (0, import_chunk_L7EZFBB4.executeSeedCommand)({ commandFromConfig: seedCommand, extraArgs });
222
+ const successfulSeeding = await (0, import_chunk_PHXLQVPT.executeSeedCommand)({ commandFromConfig: seedCommand, extraArgs });
220
223
  if (successfulSeeding) {
221
224
  return `
222
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_MOFG2YPJ_exports = {};
30
- __export(chunk_MOFG2YPJ_exports, {
29
+ var chunk_D6LYHB65_exports = {};
30
+ __export(chunk_D6LYHB65_exports, {
31
31
  Migrate: () => Migrate
32
32
  });
33
- module.exports = __toCommonJS(chunk_MOFG2YPJ_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");
@@ -874,8 +874,9 @@ var Migrate = class _Migrate {
874
874
  unexecutable
875
875
  };
876
876
  }
877
- async tryToRunGenerate() {
877
+ async tryToRunGenerate(datasourceInfo) {
878
878
  if (!this.schemaContext) throw new Error("this.schemaContext is undefined");
879
+ const skipEngines = (0, import_internals.isPrismaPostgres)(datasourceInfo.url);
879
880
  const message = [];
880
881
  process.stdout.write("\n");
881
882
  log_update_default(`Running generate... ${(0, import_chunk_SKRR5WT4.dim)("(Use --skip-generate to skip the generators)")}`);
@@ -883,6 +884,7 @@ var Migrate = class _Migrate {
883
884
  schemaContext: this.schemaContext,
884
885
  printDownloadProgress: true,
885
886
  version: import_engines_version.enginesVersion,
887
+ noEngine: skipEngines,
886
888
  registry: import_client_generator_registry.defaultRegistry.toInternal()
887
889
  });
888
890
  for (const generator of generators) {