@prisma/migrate 6.5.0-dev.1 → 6.5.0-dev.11

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 (110) hide show
  1. package/dist/CLI.js +3 -4
  2. package/dist/Migrate.js +6 -7
  3. package/dist/SchemaEngine.js +6 -7
  4. package/dist/bin.js +116 -146
  5. package/dist/{chunk-WOOPRG54.js → chunk-255BRND3.js} +7 -14
  6. package/dist/{chunk-V5LEZ5BX.js → chunk-2NJLJFGC.js} +634 -807
  7. package/dist/{chunk-75EIHNAH.js → chunk-2NMFKGXM.js} +5 -6
  8. package/dist/chunk-3WC4XD74.js +98 -0
  9. package/dist/chunk-4EV2RVXY.js +226 -0
  10. package/dist/{chunk-YWWOSXMY.js → chunk-4JQIX6O7.js} +7 -15
  11. package/dist/{chunk-J77IRNPE.js → chunk-5VDXAE53.js} +45 -31
  12. package/dist/{chunk-M5YNQ2NP.js → chunk-6DFJIBJX.js} +5 -12
  13. package/dist/{chunk-SGCF5OHF.js → chunk-7CQBDP4H.js} +6 -13
  14. package/dist/{chunk-7IT2ZO3D.js → chunk-AHJ2N6BJ.js} +3 -9
  15. package/dist/chunk-CTPONE6G.js +65 -0
  16. package/dist/{chunk-DUCG3NRP.js → chunk-D74DU52C.js} +633 -806
  17. package/dist/{chunk-UVNSK22K.js → chunk-DDHPSYC4.js} +122 -130
  18. package/dist/{chunk-CUDKD32S.js → chunk-DIAO4W7O.js} +11 -17
  19. package/dist/{chunk-XJQP3B4W.js → chunk-DJMFXNR4.js} +7 -15
  20. package/dist/{chunk-YD7GG4WS.js → chunk-FRTPDRF2.js} +66 -74
  21. package/dist/chunk-HIFVDK2U.js +96 -0
  22. package/dist/chunk-I4EY55DC.js +195 -0
  23. package/dist/{chunk-WLJHGKMK.js → chunk-IHDN3L3R.js} +7 -8
  24. package/dist/chunk-J5FHVALZ.js +230 -0
  25. package/dist/{chunk-INC2OACE.js → chunk-JFKDSUIE.js} +3 -9
  26. package/dist/{chunk-V7DE6JTG.js → chunk-JZ75RIMZ.js} +3 -9
  27. package/dist/{chunk-AAATUOV6.js → chunk-L6KOIJJ5.js} +53 -59
  28. package/dist/{chunk-GN5BY5N2.js → chunk-LGYRZ6CV.js} +4 -10
  29. package/dist/chunk-LVLRGTYH.js +148 -0
  30. package/dist/{chunk-CQQQ436N.js → chunk-MATFO4ZW.js} +186 -200
  31. package/dist/{chunk-IFCV5MY4.js → chunk-OCQGHQED.js} +5 -11
  32. package/dist/chunk-ORL3LJOT.js +470 -0
  33. package/dist/chunk-PSYS5XVH.js +335 -0
  34. package/dist/{chunk-Q7ACZDDT.js → chunk-QOPTDDIH.js} +5 -12
  35. package/dist/chunk-QTAIWPLH.js +78 -0
  36. package/dist/{chunk-35LAJN5S.js → chunk-RP2N6UXA.js} +23 -29
  37. package/dist/chunk-RQFGRXJI.js +174 -0
  38. package/dist/{chunk-QBK5XTJE.js → chunk-RR6BKMNO.js} +3 -9
  39. package/dist/{chunk-ILJRJJ3S.js → chunk-RTGQXNX6.js} +3 -9
  40. package/dist/chunk-SKRR5WT4.js +76 -0
  41. package/dist/chunk-TM3ETZES.js +153 -0
  42. package/dist/{chunk-KPUNMK5W.js → chunk-TWPTG4XS.js} +5 -12
  43. package/dist/{chunk-6QFE3AWR.js → chunk-UP6FVCDK.js} +6 -13
  44. package/dist/{chunk-YKUZUAXA.js → chunk-V3ZMNXZC.js} +16 -23
  45. package/dist/chunk-WLPX3672.js +365 -0
  46. package/dist/chunk-WNH2ACJS.js +122 -0
  47. package/dist/{chunk-X6XGFLEF.js → chunk-YZVZCC3I.js} +25 -30
  48. package/dist/commands/DbCommand.js +3 -4
  49. package/dist/commands/DbDrop.js +9 -9
  50. package/dist/commands/DbExecute.js +7 -8
  51. package/dist/commands/DbPull.js +18 -19
  52. package/dist/commands/DbPush.js +12 -13
  53. package/dist/commands/DbSeed.js +4 -5
  54. package/dist/commands/MigrateCommand.js +3 -4
  55. package/dist/commands/MigrateDeploy.js +13 -14
  56. package/dist/commands/MigrateDev.js +17 -18
  57. package/dist/commands/MigrateDiff.js +8 -9
  58. package/dist/commands/MigrateReset.js +15 -16
  59. package/dist/commands/MigrateResolve.js +11 -12
  60. package/dist/commands/MigrateStatus.js +11 -12
  61. package/dist/index.js +60 -77
  62. package/dist/internals/src/index.d.ts +3 -0
  63. package/dist/internals/src/utils/isInContainer.d.ts +5 -0
  64. package/dist/internals/src/utils/isInNpmLifecycleHook.d.ts +4 -0
  65. package/dist/internals/src/utils/maybeInGitHook.d.ts +9 -0
  66. package/dist/migrate/src/commands/MigrateDev.d.ts +1 -1
  67. package/dist/{multipart-parser-73VM3J4A.js → multipart-parser-NDLECNMN.js} +527 -561
  68. package/dist/utils/byline.js +5 -6
  69. package/dist/utils/captureStdout.js +2 -3
  70. package/dist/utils/countModelsAndTypes.js +2 -3
  71. package/dist/utils/ensureDatabaseExists.js +8 -9
  72. package/dist/utils/errors.js +8 -9
  73. package/dist/utils/flagErrors.js +5 -5
  74. package/dist/utils/getDatabaseVersionSafe.js +6 -7
  75. package/dist/utils/getSchemaPathAndPrint.js +4 -5
  76. package/dist/utils/handleEvaluateDataloss.js +3 -4
  77. package/dist/utils/introspectSql.js +6 -6
  78. package/dist/utils/isSchemaEmpty.js +2 -3
  79. package/dist/utils/printDatasource.js +3 -4
  80. package/dist/utils/printDatasources.js +3 -4
  81. package/dist/utils/printFiles.js +5 -6
  82. package/dist/utils/printIntrospectedSchema.js +2 -3
  83. package/dist/utils/printMigrationId.js +4 -5
  84. package/dist/utils/promptForMigrationName.js +2 -3
  85. package/dist/utils/removeSchemaFiles.js +2 -3
  86. package/dist/utils/replaceOrAddDatasource.js +2 -3
  87. package/dist/utils/replaceOrAddDatasource.test.js +7 -8
  88. package/dist/utils/saveSchemaFiles.js +2 -3
  89. package/dist/utils/seed.js +6 -7
  90. package/dist/utils/setupMSSQL.js +13 -13
  91. package/dist/utils/setupMongo.js +3 -3
  92. package/dist/utils/spinner.js +2 -3
  93. package/dist/utils/unixSocket.js +2 -3
  94. package/dist/views/handleViewsIO.js +2 -3
  95. package/package.json +7 -7
  96. package/dist/chunk-26XQQ4AG.js +0 -386
  97. package/dist/chunk-2RSEPJFX.js +0 -165
  98. package/dist/chunk-4B2LXK4R.js +0 -207
  99. package/dist/chunk-4UJBOCZJ.js +0 -130
  100. package/dist/chunk-5HZLCY6X.js +0 -161
  101. package/dist/chunk-6TE2RIPN.js +0 -80
  102. package/dist/chunk-7S3Q4MCN.js +0 -480
  103. package/dist/chunk-AOX7CJAS.js +0 -234
  104. package/dist/chunk-FF3526PX.js +0 -279
  105. package/dist/chunk-FUSFURVP.js +0 -86
  106. package/dist/chunk-GCTCQLOF.js +0 -365
  107. package/dist/chunk-K44VNAFW.js +0 -189
  108. package/dist/chunk-O4BT6W33.js +0 -104
  109. package/dist/chunk-TKAGMA5K.js +0 -72
  110. package/dist/chunk-U374EXYQ.js +0 -106
@@ -1,234 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var chunk_AOX7CJAS_exports = {};
30
- __export(chunk_AOX7CJAS_exports, {
31
- DbExecute: () => DbExecute,
32
- init_DbExecute: () => init_DbExecute
33
- });
34
- module.exports = __toCommonJS(chunk_AOX7CJAS_exports);
35
- var import_chunk_UVNSK22K = require("./chunk-UVNSK22K.js");
36
- var import_chunk_6TE2RIPN = require("./chunk-6TE2RIPN.js");
37
- var import_chunk_WWAWV7DQ = require("./chunk-WWAWV7DQ.js");
38
- var import_internals = require("@prisma/internals");
39
- var import_fs = __toESM(require("fs"));
40
- var import_path = __toESM(require("path"));
41
- var require_get_stdin = (0, import_chunk_WWAWV7DQ.__commonJS)({
42
- "../../node_modules/.pnpm/get-stdin@8.0.0/node_modules/get-stdin/index.js"(exports, module2) {
43
- "use strict";
44
- var { stdin } = process;
45
- module2.exports = async () => {
46
- let result = "";
47
- if (stdin.isTTY) {
48
- return result;
49
- }
50
- stdin.setEncoding("utf8");
51
- for await (const chunk of stdin) {
52
- result += chunk;
53
- }
54
- return result;
55
- };
56
- module2.exports.buffer = async () => {
57
- const result = [];
58
- let length = 0;
59
- if (stdin.isTTY) {
60
- return Buffer.concat([]);
61
- }
62
- for await (const chunk of stdin) {
63
- result.push(chunk);
64
- length += chunk.length;
65
- }
66
- return Buffer.concat(result, length);
67
- };
68
- }
69
- });
70
- var import_get_stdin, helpOptions, _DbExecute, DbExecute;
71
- var init_DbExecute = (0, import_chunk_WWAWV7DQ.__esm)({
72
- "src/commands/DbExecute.ts"() {
73
- import_get_stdin = (0, import_chunk_WWAWV7DQ.__toESM)(require_get_stdin());
74
- (0, import_chunk_6TE2RIPN.init_colors)();
75
- (0, import_chunk_UVNSK22K.init_Migrate)();
76
- helpOptions = (0, import_internals.format)(
77
- `${(0, import_chunk_6TE2RIPN.bold)("Usage")}
78
-
79
- ${(0, import_chunk_6TE2RIPN.dim)("$")} prisma db execute [options]
80
-
81
- ${(0, import_chunk_6TE2RIPN.bold)("Options")}
82
-
83
- -h, --help Display this help message
84
- --config Custom path to your Prisma config file
85
-
86
- ${(0, import_chunk_6TE2RIPN.italic)("Datasource input, only 1 must be provided:")}
87
- --url URL of the datasource to run the command on
88
- --schema Path to your Prisma schema file to take the datasource URL from
89
-
90
- ${(0, import_chunk_6TE2RIPN.italic)("Script input, only 1 must be provided:")}
91
- --file Path to a file. The content will be sent as the script to be executed
92
-
93
- ${(0, import_chunk_6TE2RIPN.bold)("Flags")}
94
-
95
- --stdin Use the terminal standard input as the script to be executed`
96
- );
97
- _DbExecute = class _DbExecute2 {
98
- static new() {
99
- return new _DbExecute2();
100
- }
101
- async parse(argv, config) {
102
- const args = (0, import_internals.arg)(
103
- argv,
104
- {
105
- "--help": Boolean,
106
- "-h": "--help",
107
- "--config": String,
108
- "--stdin": Boolean,
109
- "--file": String,
110
- "--schema": String,
111
- "--url": String,
112
- "--telemetry-information": String
113
- },
114
- false
115
- );
116
- if ((0, import_internals.isError)(args)) {
117
- return this.help(args.message);
118
- }
119
- await (0, import_internals.checkUnsupportedDataProxy)("db execute", args, config.schema, !args["--url"]);
120
- if (args["--help"]) {
121
- return this.help();
122
- }
123
- await (0, import_internals.loadEnvFile)({ schemaPath: args["--schema"], printMessage: false, config });
124
- if (args["--stdin"] && args["--file"]) {
125
- throw new Error(
126
- `--stdin and --file cannot be used at the same time. Only 1 must be provided.
127
- See \`${(0, import_chunk_6TE2RIPN.green)((0, import_internals.getCommandWithExecutor)("prisma db execute -h"))}\``
128
- );
129
- } else if (!args["--stdin"] && !args["--file"]) {
130
- throw new Error(
131
- `Either --stdin or --file must be provided.
132
- See \`${(0, import_chunk_6TE2RIPN.green)((0, import_internals.getCommandWithExecutor)("prisma db execute -h"))}\``
133
- );
134
- }
135
- if (args["--url"] && args["--schema"]) {
136
- throw new Error(
137
- `--url and --schema cannot be used at the same time. Only 1 must be provided.
138
- See \`${(0, import_chunk_6TE2RIPN.green)((0, import_internals.getCommandWithExecutor)("prisma db execute -h"))}\``
139
- );
140
- } else if (!args["--url"] && !args["--schema"]) {
141
- throw new Error(
142
- `Either --url or --schema must be provided.
143
- See \`${(0, import_chunk_6TE2RIPN.green)((0, import_internals.getCommandWithExecutor)("prisma db execute -h"))}\``
144
- );
145
- }
146
- let script = "";
147
- if (args["--file"]) {
148
- try {
149
- script = import_fs.default.readFileSync(import_path.default.resolve(args["--file"]), "utf-8");
150
- } catch (e) {
151
- if (e.code === "ENOENT") {
152
- throw new Error(`Provided --file at ${args["--file"]} doesn't exist.`);
153
- } else {
154
- console.error(`An error occurred while reading the provided --file at ${args["--file"]}`);
155
- throw e;
156
- }
157
- }
158
- }
159
- if (args["--stdin"]) {
160
- script = await (0, import_get_stdin.default)();
161
- }
162
- let datasourceType;
163
- if (args["--url"]) {
164
- datasourceType = {
165
- tag: "url",
166
- url: args["--url"]
167
- };
168
- } else {
169
- const schemaWithPath = await (0, import_internals.getSchemaWithPath)(args["--schema"], config.schema);
170
- const engineConfig = await (0, import_internals.getConfig)({ datamodel: schemaWithPath.schemas });
171
- datasourceType = {
172
- tag: "schema",
173
- ...(0, import_internals.toSchemasWithConfigDir)(schemaWithPath, engineConfig)
174
- };
175
- }
176
- const migrate = new import_chunk_UVNSK22K.Migrate();
177
- try {
178
- await migrate.engine.dbExecute({
179
- script,
180
- datasourceType
181
- });
182
- } finally {
183
- migrate.stop();
184
- }
185
- return `Script executed successfully.`;
186
- }
187
- help(error) {
188
- if (error) {
189
- throw new import_internals.HelpError(`
190
- ${error}
191
-
192
- ${helpOptions}`);
193
- }
194
- return _DbExecute2.help;
195
- }
196
- };
197
- _DbExecute.help = (0, import_internals.format)(`
198
- ${process.platform === "win32" ? "" : "\u{1F4DD} "}Execute native commands to your database
199
-
200
- This command takes as input a datasource, using ${(0, import_chunk_6TE2RIPN.green)(`--url`)} or ${(0, import_chunk_6TE2RIPN.green)(`--schema`)} and a script, using ${(0, import_chunk_6TE2RIPN.green)(
201
- `--stdin`
202
- )} or ${(0, import_chunk_6TE2RIPN.green)(`--file`)}.
203
- The input parameters are mutually exclusive, only 1 of each (datasource & script) must be provided.
204
-
205
- The output of the command is connector-specific, and is not meant for returning data, but only to report success or failure.
206
-
207
- On SQL databases, this command takes as input a SQL script.
208
- The whole script will be sent as a single command to the database.
209
-
210
- ${(0, import_chunk_6TE2RIPN.italic)(`This command is currently not supported on MongoDB.`)}
211
-
212
- ${helpOptions}
213
- ${(0, import_chunk_6TE2RIPN.bold)("Examples")}
214
-
215
- Execute the content of a SQL script file to the datasource URL taken from the schema
216
- ${(0, import_chunk_6TE2RIPN.dim)("$")} prisma db execute
217
- --file ./script.sql \\
218
- --schema schema.prisma
219
-
220
- Execute the SQL script from stdin to the datasource URL specified via the \`DATABASE_URL\` environment variable
221
- ${(0, import_chunk_6TE2RIPN.dim)("$")} echo 'TRUNCATE TABLE dev;' | \\
222
- prisma db execute \\
223
- --stdin \\
224
- --url="$DATABASE_URL"
225
-
226
- Like previous example, but exposing the datasource url credentials to your terminal history
227
- ${(0, import_chunk_6TE2RIPN.dim)("$")} echo 'TRUNCATE TABLE dev;' | \\
228
- prisma db execute \\
229
- --stdin \\
230
- --url="mysql://root:root@localhost/mydb"
231
- `);
232
- DbExecute = _DbExecute;
233
- }
234
- });
@@ -1,279 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var chunk_FF3526PX_exports = {};
30
- __export(chunk_FF3526PX_exports, {
31
- DbPush: () => DbPush,
32
- init_DbPush: () => init_DbPush
33
- });
34
- module.exports = __toCommonJS(chunk_FF3526PX_exports);
35
- var import_chunk_UVNSK22K = require("./chunk-UVNSK22K.js");
36
- var import_chunk_U374EXYQ = require("./chunk-U374EXYQ.js");
37
- var import_chunk_M5YNQ2NP = require("./chunk-M5YNQ2NP.js");
38
- var import_chunk_Q7ACZDDT = require("./chunk-Q7ACZDDT.js");
39
- var import_chunk_XJQP3B4W = require("./chunk-XJQP3B4W.js");
40
- var import_chunk_6TE2RIPN = require("./chunk-6TE2RIPN.js");
41
- var import_chunk_WWAWV7DQ = require("./chunk-WWAWV7DQ.js");
42
- var import_internals = require("@prisma/internals");
43
- var import_prompts = __toESM(require("prompts"));
44
- var _DbPush, DbPush;
45
- var init_DbPush = (0, import_chunk_WWAWV7DQ.__esm)({
46
- "src/commands/DbPush.ts"() {
47
- (0, import_chunk_6TE2RIPN.init_colors)();
48
- (0, import_chunk_UVNSK22K.init_Migrate)();
49
- (0, import_chunk_XJQP3B4W.init_ensureDatabaseExists)();
50
- (0, import_chunk_U374EXYQ.init_errors)();
51
- (0, import_chunk_M5YNQ2NP.init_getSchemaPathAndPrint)();
52
- (0, import_chunk_Q7ACZDDT.init_printDatasource)();
53
- _DbPush = class _DbPush2 {
54
- static new() {
55
- return new _DbPush2();
56
- }
57
- async parse(argv, config) {
58
- const args = (0, import_internals.arg)(
59
- argv,
60
- {
61
- "--help": Boolean,
62
- "-h": "--help",
63
- "--accept-data-loss": Boolean,
64
- "--force-reset": Boolean,
65
- "--skip-generate": Boolean,
66
- "--schema": String,
67
- "--config": String,
68
- "--telemetry-information": String
69
- },
70
- false
71
- );
72
- if ((0, import_internals.isError)(args)) {
73
- return this.help(args.message);
74
- }
75
- await (0, import_internals.checkUnsupportedDataProxy)("db push", args, config.schema, true);
76
- if (args["--help"]) {
77
- return this.help();
78
- }
79
- await (0, import_internals.loadEnvFile)({ schemaPath: args["--schema"], printMessage: true, config });
80
- const { schemaPath } = await (0, import_chunk_M5YNQ2NP.getSchemaPathAndPrint)(args["--schema"], config.schema);
81
- const datasourceInfo = await (0, import_chunk_XJQP3B4W.getDatasourceInfo)({ schemaPath });
82
- (0, import_chunk_Q7ACZDDT.printDatasource)({ datasourceInfo });
83
- const migrate = new import_chunk_UVNSK22K.Migrate(schemaPath);
84
- try {
85
- const wasDbCreated = await (0, import_chunk_XJQP3B4W.ensureDatabaseExists)("push", schemaPath);
86
- if (wasDbCreated) {
87
- process.stdout.write("\n" + wasDbCreated + "\n");
88
- }
89
- } catch (e) {
90
- process.stdout.write("\n");
91
- throw e;
92
- }
93
- let wasDatabaseReset = false;
94
- if (args["--force-reset"]) {
95
- process.stdout.write("\n");
96
- try {
97
- await migrate.reset();
98
- } catch (e) {
99
- migrate.stop();
100
- throw e;
101
- }
102
- let successfulResetMsg = `The ${datasourceInfo.prettyProvider} database`;
103
- if (datasourceInfo.dbName) {
104
- successfulResetMsg += ` "${datasourceInfo.dbName}"`;
105
- }
106
- const schemasLength = datasourceInfo.schemas?.length || 0;
107
- if (datasourceInfo.schemas && schemasLength > 0) {
108
- successfulResetMsg += ` schema${schemasLength > 1 ? "s" : ""} "${datasourceInfo.schemas.join(", ")}"`;
109
- } else if (datasourceInfo.schema) {
110
- successfulResetMsg += ` schema "${datasourceInfo.schema}"`;
111
- }
112
- if (datasourceInfo.dbLocation) {
113
- successfulResetMsg += ` at "${datasourceInfo.dbLocation}"`;
114
- }
115
- successfulResetMsg += ` ${schemasLength > 1 ? "were" : "was"} successfully reset.
116
- `;
117
- process.stdout.write(successfulResetMsg);
118
- wasDatabaseReset = true;
119
- }
120
- const before = Math.round(performance.now());
121
- let migration;
122
- try {
123
- migration = await migrate.push({
124
- force: args["--accept-data-loss"]
125
- });
126
- } catch (e) {
127
- migrate.stop();
128
- throw e;
129
- }
130
- if (migration.unexecutable && migration.unexecutable.length > 0) {
131
- const messages = [];
132
- messages.push(`${(0, import_chunk_6TE2RIPN.bold)((0, import_chunk_6TE2RIPN.red)("\n\u26A0\uFE0F We found changes that cannot be executed:\n"))}`);
133
- for (const item of migration.unexecutable) {
134
- messages.push(` \u2022 ${item}`);
135
- }
136
- process.stdout.write("\n");
137
- if (!(0, import_internals.canPrompt)()) {
138
- migrate.stop();
139
- throw new Error(`${messages.join("\n")}
140
-
141
- Use the --force-reset flag to drop the database before push like ${(0, import_chunk_6TE2RIPN.bold)(
142
- (0, import_chunk_6TE2RIPN.green)((0, import_internals.getCommandWithExecutor)("prisma db push --force-reset"))
143
- )}
144
- ${(0, import_chunk_6TE2RIPN.bold)((0, import_chunk_6TE2RIPN.red)("All data will be lost."))}
145
- `);
146
- } else {
147
- process.stdout.write(`${messages.join("\n")}
148
-
149
- `);
150
- }
151
- process.stdout.write("\n");
152
- const confirmation = await (0, import_prompts.default)({
153
- type: "confirm",
154
- name: "value",
155
- message: `To apply this change we need to reset the database, do you want to continue? ${(0, import_chunk_6TE2RIPN.red)(
156
- "All data will be lost"
157
- )}.`
158
- });
159
- if (!confirmation.value) {
160
- process.stdout.write("Reset cancelled.\n");
161
- migrate.stop();
162
- process.exit(130);
163
- }
164
- try {
165
- await migrate.reset();
166
- if (datasourceInfo.dbName && datasourceInfo.dbLocation) {
167
- process.stdout.write(
168
- `The ${datasourceInfo.prettyProvider} database "${datasourceInfo.dbName}" from "${datasourceInfo.dbLocation}" was successfully reset.
169
- `
170
- );
171
- } else {
172
- process.stdout.write(`The ${datasourceInfo.prettyProvider} database was successfully reset.
173
- `);
174
- }
175
- wasDatabaseReset = true;
176
- await migrate.push({});
177
- } catch (e) {
178
- migrate.stop();
179
- throw e;
180
- }
181
- }
182
- if (migration.warnings && migration.warnings.length > 0) {
183
- process.stdout.write((0, import_chunk_6TE2RIPN.bold)((0, import_chunk_6TE2RIPN.yellow)(`
184
- \u26A0\uFE0F There might be data loss when applying the changes:
185
-
186
- `)));
187
- for (const warning of migration.warnings) {
188
- process.stdout.write(` \u2022 ${warning}
189
-
190
- `);
191
- }
192
- process.stdout.write("\n");
193
- if (!args["--accept-data-loss"]) {
194
- if (!(0, import_internals.canPrompt)()) {
195
- migrate.stop();
196
- throw new import_chunk_U374EXYQ.DbPushIgnoreWarningsWithFlagError();
197
- }
198
- process.stdout.write("\n");
199
- const confirmation = await (0, import_prompts.default)({
200
- type: "confirm",
201
- name: "value",
202
- message: `Do you want to ignore the warning(s)?`
203
- });
204
- if (!confirmation.value) {
205
- process.stdout.write("Push cancelled.\n");
206
- migrate.stop();
207
- process.exit(130);
208
- }
209
- try {
210
- await migrate.push({
211
- force: true
212
- });
213
- } catch (e) {
214
- migrate.stop();
215
- throw e;
216
- }
217
- }
218
- }
219
- migrate.stop();
220
- if (!wasDatabaseReset && migration.warnings.length === 0 && migration.executedSteps === 0) {
221
- process.stdout.write(`
222
- The database is already in sync with the Prisma schema.
223
- `);
224
- } else {
225
- const migrationTimeMessage = `Done in ${(0, import_internals.formatms)(Math.round(performance.now()) - before)}`;
226
- const rocketEmoji = process.platform === "win32" ? "" : "\u{1F680} ";
227
- const migrationSuccessStdMessage = "Your database is now in sync with your Prisma schema.";
228
- const migrationSuccessMongoMessage = "Your database indexes are now in sync with your Prisma schema.";
229
- const provider = (0, import_internals.protocolToConnectorType)(`${datasourceInfo.url?.split(":")[0]}:`);
230
- process.stdout.write(
231
- `
232
- ${rocketEmoji}${provider === "mongodb" ? migrationSuccessMongoMessage : migrationSuccessStdMessage} ${migrationTimeMessage}
233
- `
234
- );
235
- }
236
- if (!process.env.PRISMA_MIGRATE_SKIP_GENERATE && !args["--skip-generate"]) {
237
- await migrate.tryToRunGenerate(datasourceInfo);
238
- }
239
- return ``;
240
- }
241
- help(error) {
242
- if (error) {
243
- return new import_internals.HelpError(`
244
- ${(0, import_chunk_6TE2RIPN.bold)((0, import_chunk_6TE2RIPN.red)(`!`))} ${error}
245
- ${_DbPush2.help}`);
246
- }
247
- return _DbPush2.help;
248
- }
249
- };
250
- _DbPush.help = (0, import_internals.format)(`
251
- ${process.platform === "win32" ? "" : "\u{1F64C} "}Push the state from your Prisma schema to your database
252
-
253
- ${(0, import_chunk_6TE2RIPN.bold)("Usage")}
254
-
255
- ${(0, import_chunk_6TE2RIPN.dim)("$")} prisma db push [options]
256
-
257
- ${(0, import_chunk_6TE2RIPN.bold)("Options")}
258
-
259
- -h, --help Display this help message
260
- --config Custom path to your Prisma config file
261
- --schema Custom path to your Prisma schema
262
- --accept-data-loss Ignore data loss warnings
263
- --force-reset Force a reset of the database before push
264
- --skip-generate Skip triggering generators (e.g. Prisma Client)
265
-
266
- ${(0, import_chunk_6TE2RIPN.bold)("Examples")}
267
-
268
- Push the Prisma schema state to the database
269
- ${(0, import_chunk_6TE2RIPN.dim)("$")} prisma db push
270
-
271
- Specify a schema
272
- ${(0, import_chunk_6TE2RIPN.dim)("$")} prisma db push --schema=./schema.prisma
273
-
274
- Ignore data loss warnings
275
- ${(0, import_chunk_6TE2RIPN.dim)("$")} prisma db push --accept-data-loss
276
- `);
277
- DbPush = _DbPush;
278
- }
279
- });
@@ -1,86 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var chunk_FUSFURVP_exports = {};
20
- __export(chunk_FUSFURVP_exports, {
21
- CLI: () => CLI,
22
- init_CLI: () => init_CLI
23
- });
24
- module.exports = __toCommonJS(chunk_FUSFURVP_exports);
25
- var import_chunk_6TE2RIPN = require("./chunk-6TE2RIPN.js");
26
- var import_chunk_WWAWV7DQ = require("./chunk-WWAWV7DQ.js");
27
- var import_internals = require("@prisma/internals");
28
- var _CLI, CLI;
29
- var init_CLI = (0, import_chunk_WWAWV7DQ.__esm)({
30
- "src/CLI.ts"() {
31
- (0, import_chunk_6TE2RIPN.init_colors)();
32
- _CLI = class _CLI2 {
33
- constructor(cmds) {
34
- this.cmds = cmds;
35
- }
36
- static new(cmds) {
37
- return new _CLI2(cmds);
38
- }
39
- async parse(argv, config) {
40
- const args = (0, import_internals.arg)(argv, {
41
- "--help": Boolean,
42
- "-h": "--help",
43
- "--config": String,
44
- "--json": Boolean,
45
- // for -v
46
- "--experimental": Boolean,
47
- "--preview-feature": Boolean,
48
- "--early-access": Boolean,
49
- "--telemetry-information": String
50
- });
51
- if ((0, import_internals.isError)(args)) {
52
- return this.help(args.message);
53
- }
54
- if (args._.length === 0 || args["--help"]) {
55
- return this.help();
56
- }
57
- const cmdName = args._[0];
58
- const cmd = this.cmds[cmdName];
59
- if (cmd) {
60
- let argsForCmd;
61
- if (args["--experimental"]) {
62
- argsForCmd = [...args._.slice(1), `--experimental=${args["--experimental"]}`];
63
- } else if (args["--preview-feature"]) {
64
- argsForCmd = [...args._.slice(1), `--preview-feature=${args["--preview-feature"]}`];
65
- } else if (args["--early-access"]) {
66
- argsForCmd = [...args._.slice(1), `--early-access=${args["--early-access"]}`];
67
- } else {
68
- argsForCmd = args._.slice(1);
69
- }
70
- return cmd.parse(argsForCmd, config);
71
- }
72
- return (0, import_internals.unknownCommand)(this.help(), args._[0]);
73
- }
74
- help(error) {
75
- if (error) {
76
- return new import_internals.HelpError(`
77
- ${(0, import_chunk_6TE2RIPN.bold)((0, import_chunk_6TE2RIPN.red)(`!`))} ${error}
78
- ${_CLI2.help}`);
79
- }
80
- return _CLI2.help;
81
- }
82
- };
83
- _CLI.help = (0, import_internals.format)(`This is the internal CLI for @prisma/migrate`);
84
- CLI = _CLI;
85
- }
86
- });