@prisma/migrate 6.6.0-dev.4 → 6.6.0-dev.40
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.
- package/dist/CLI.js +3 -3
- package/dist/Migrate.js +8 -6
- package/dist/SchemaEngine.js +5 -5
- package/dist/bin.js +48 -47
- package/dist/chunk-23DZXSTI.js +62 -0
- package/dist/{chunk-WWAWV7DQ.js → chunk-2ESYSVXG.js} +3 -27
- package/dist/{chunk-LKTTJWFT.js → chunk-2R6DII47.js} +5 -5
- package/dist/chunk-33LPBNDX.js +1399 -0
- package/dist/{chunk-GG54LOYV.js → chunk-3PIR4R46.js} +45 -44
- package/dist/{chunk-V3ZMNXZC.js → chunk-5LKIRKDL.js} +307 -382
- package/dist/{chunk-IR55GBON.js → chunk-5LTDMS3H.js} +18 -18
- package/dist/{chunk-LOGAFLCN.js → chunk-5R44VVVX.js} +29 -29
- package/dist/{chunk-ZYKVWZ6H.js → chunk-6UMA6TED.js} +347 -369
- package/dist/{chunk-DJMFXNR4.js → chunk-74LUB4XX.js} +56 -57
- package/dist/{chunk-RP2N6UXA.js → chunk-AI6DH66U.js} +6 -6
- package/dist/{chunk-G2XUUMKH.js → chunk-B4SUSDC2.js} +31 -39
- package/dist/{chunk-Q3ZLC44N.js → chunk-CKRN45WP.js} +57 -66
- package/dist/{chunk-ZOEKRXDP.js → chunk-D2DGSPW6.js} +29 -55
- package/dist/{chunk-W2SZNLK4.js → chunk-EJG7GKM7.js} +37 -39
- package/dist/{chunk-5PSO7BDO.js → chunk-EJUXYFV3.js} +15 -15
- package/dist/{chunk-N3KYWSX2.js → chunk-GAKKKF5T.js} +55 -49
- package/dist/{chunk-N4XTKFY6.js → chunk-GKHRL6AR.js} +39 -38
- package/dist/{chunk-CQZFVAXC.js → chunk-HHVLUI3H.js} +42 -41
- package/dist/{chunk-MCWCB2AX.js → chunk-IINN7QUV.js} +170 -643
- package/dist/{chunk-HCBZB4XC.js → chunk-KN2W5IP7.js} +53 -52
- package/dist/{chunk-255BRND3.js → chunk-KRQEFTDT.js} +6 -6
- package/dist/{chunk-VVKOFN3Y.js → chunk-LLO7YF56.js} +44 -46
- package/dist/{chunk-VZ23KD5C.js → chunk-NGQA5JTN.js} +8 -10
- package/dist/{chunk-MKK3GSDF.js → chunk-NIKXBMZL.js} +5 -5
- package/dist/{chunk-KS7IEA6Z.js → chunk-O723A5JE.js} +50 -52
- package/dist/{chunk-MATFO4ZW.js → chunk-OEWQACEH.js} +38 -39
- package/dist/chunk-PDCXVUV3.js +883 -0
- package/dist/{chunk-WI2A2TQE.js → chunk-QJT4H5N6.js} +91 -92
- package/dist/{chunk-V5TUSOJX.js → chunk-SQKGZVG3.js} +45 -45
- package/dist/{chunk-EGPJABTW.js → chunk-TGV6QGEF.js} +69 -69
- package/dist/chunk-URKH6SE2.js +479 -0
- package/dist/chunk-V6PVGSDJ.js +76 -0
- package/dist/{chunk-DLLXDCI2.js → chunk-VAJ4VX67.js} +5 -6
- package/dist/{chunk-OCQGHQED.js → chunk-YBX7R3MT.js} +12 -12
- package/dist/{chunk-A6PMXMMT.js → chunk-ZB5NPOJW.js} +13 -13
- package/dist/{chunk-2JZLJQDC.js → chunk-ZRHBLHAM.js} +346 -368
- package/dist/commands/DbCommand.js +3 -3
- package/dist/commands/DbDrop.js +4 -5
- package/dist/commands/DbExecute.js +9 -7
- package/dist/commands/DbPull.js +12 -11
- package/dist/commands/DbPush.js +10 -9
- package/dist/commands/DbSeed.js +4 -5
- package/dist/commands/MigrateCommand.js +3 -3
- package/dist/commands/MigrateDeploy.js +12 -11
- package/dist/commands/MigrateDev.js +14 -13
- package/dist/commands/MigrateDiff.js +12 -10
- package/dist/commands/MigrateReset.js +13 -12
- package/dist/commands/MigrateResolve.js +10 -9
- package/dist/commands/MigrateStatus.js +10 -9
- package/dist/index.js +52 -50
- package/dist/internals/src/cli/checkUnsupportedDataProxy.d.ts +12 -17
- package/dist/internals/src/cli/directoryConfig.d.ts +7 -0
- package/dist/internals/src/cli/schemaContext.d.ts +58 -0
- package/dist/internals/src/engine-commands/getConfig.d.ts +0 -4
- package/dist/internals/src/engine-commands/getDmmf.d.ts +1 -5
- package/dist/internals/src/engine-commands/lintSchema.d.ts +1 -1
- package/dist/internals/src/errorReporting.d.ts +0 -1
- package/dist/internals/src/get-generators/getGenerators.d.ts +7 -3
- package/dist/internals/src/index.d.ts +3 -1
- package/dist/internals/src/migrateTypes.d.ts +63 -0
- package/dist/internals/src/panic.d.ts +1 -4
- package/dist/internals/src/utils/extractPreviewFeatures.d.ts +2 -2
- package/dist/internals/src/utils/schemaFileInput.d.ts +0 -4
- package/dist/internals/src/utils/toSchemasContainer.d.ts +2 -3
- package/dist/migrate/src/Migrate.d.ts +7 -5
- package/dist/migrate/src/SchemaEngine.d.ts +5 -9
- package/dist/migrate/src/types.d.ts +14 -10
- package/dist/migrate/src/utils/createMigration.d.ts +21 -0
- package/dist/migrate/src/utils/ensureDatabaseExists.d.ts +4 -6
- package/dist/migrate/src/utils/introspectSql.d.ts +2 -1
- package/dist/migrate/src/utils/listMigrations.d.ts +9 -0
- package/dist/migrate/src/utils/seed.d.ts +0 -2
- package/dist/migrate/src/views/handleViewsIO.d.ts +2 -2
- package/dist/{multipart-parser-54WEFGGN-NLZG56KM.js → multipart-parser-ASKQAOL4-WZ47HU6G.js} +92 -125
- package/dist/{multipart-parser-NDLECNMN.js → multipart-parser-QCI3Y5IB.js} +66 -68
- package/dist/types.js +1 -1
- package/dist/{typescript-WN4QH2CP.js → typescript-2LKASCMC.js} +33 -33
- package/dist/{typescript-AILDXN3I.js → typescript-H3AVJ6KX.js} +32 -32
- package/dist/utils/byline.js +1 -1
- package/dist/utils/captureStdout.js +3 -3
- package/dist/utils/countModelsAndTypes.js +1 -1
- package/dist/utils/createMigration.js +27 -0
- package/dist/utils/customColors.js +1 -1
- package/dist/utils/ensureDatabaseExists.js +7 -7
- package/dist/utils/errors.js +1 -1
- package/dist/utils/flagErrors.js +1 -1
- package/dist/utils/getDatabaseVersionSafe.js +5 -5
- package/dist/utils/getSchemaPathAndPrint.js +1 -1
- package/dist/utils/handleEvaluateDataloss.js +1 -1
- package/dist/utils/introspectSql.js +5 -5
- package/dist/utils/isSchemaEmpty.js +1 -1
- package/dist/utils/listMigrations.js +25 -0
- package/dist/utils/now.js +1 -1
- package/dist/utils/printDatasource.js +1 -1
- package/dist/utils/printDatasources.js +5 -5
- package/dist/utils/printFiles.js +5 -5
- package/dist/utils/printIntrospectedSchema.js +1 -1
- package/dist/utils/printMigrationId.js +1 -1
- package/dist/utils/promptForMigrationName.js +3 -3
- package/dist/utils/removeSchemaFiles.js +1 -1
- package/dist/utils/replaceOrAddDatasource.js +1 -1
- package/dist/utils/replaceOrAddDatasource.test.js +1 -1
- package/dist/utils/saveSchemaFiles.js +1 -1
- package/dist/utils/seed.js +4 -7
- package/dist/utils/setupCockroach.js +3 -3
- package/dist/utils/setupMSSQL.js +759 -675
- package/dist/utils/setupMongo.js +552 -552
- package/dist/utils/setupMysql.js +508 -563
- package/dist/utils/setupPostgres.js +3 -3
- package/dist/utils/spinner.js +4 -3
- package/dist/utils/test-handlePanic.js +1 -30
- package/dist/utils/unixSocket.js +1 -1
- package/dist/views/handleViewsIO.js +3 -3
- package/package.json +9 -9
- package/dist/chunk-J46BJQHT.js +0 -268
- package/dist/chunk-KOF4LGTS.js +0 -1817
- package/dist/chunk-YYPMC5FN.js +0 -1407
- package/dist/internals/src/get-generators/utils/check-feature-flags/checkFeatureFlags.d.ts +0 -8
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,35 +17,30 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
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
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var
|
|
20
|
-
__export(
|
|
29
|
+
var chunk_74LUB4XX_exports = {};
|
|
30
|
+
__export(chunk_74LUB4XX_exports, {
|
|
21
31
|
ensureCanConnectToDatabase: () => ensureCanConnectToDatabase,
|
|
22
32
|
ensureDatabaseExists: () => ensureDatabaseExists,
|
|
23
|
-
getDatasourceInfo: () => getDatasourceInfo,
|
|
24
33
|
getDbLocation: () => getDbLocation,
|
|
34
|
+
parseDatasourceInfo: () => parseDatasourceInfo,
|
|
25
35
|
prettifyProvider: () => prettifyProvider
|
|
26
36
|
});
|
|
27
|
-
module.exports = __toCommonJS(
|
|
37
|
+
module.exports = __toCommonJS(chunk_74LUB4XX_exports);
|
|
28
38
|
var import_chunk_TWPTG4XS = require("./chunk-TWPTG4XS.js");
|
|
29
39
|
var import_chunk_SKRR5WT4 = require("./chunk-SKRR5WT4.js");
|
|
30
40
|
var import_internals = require("@prisma/internals");
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
} = {}) {
|
|
35
|
-
const schema = await (0, import_internals.getSchema)(schemaPath);
|
|
36
|
-
let config;
|
|
37
|
-
try {
|
|
38
|
-
config = await (0, import_internals.getConfig)({ datamodel: schema, ignoreEnvVarErrors: false });
|
|
39
|
-
} catch (error) {
|
|
40
|
-
if (throwIfEnvError) {
|
|
41
|
-
throw error;
|
|
42
|
-
}
|
|
43
|
-
config = await (0, import_internals.getConfig)({ datamodel: schema, ignoreEnvVarErrors: true });
|
|
44
|
-
}
|
|
45
|
-
const firstDatasource = config.datasources[0] ? config.datasources[0] : void 0;
|
|
46
|
-
if (!firstDatasource) {
|
|
41
|
+
var import_path = __toESM(require("path"));
|
|
42
|
+
function parseDatasourceInfo(datasource) {
|
|
43
|
+
if (!datasource) {
|
|
47
44
|
return {
|
|
48
45
|
name: void 0,
|
|
49
46
|
prettyProvider: void 0,
|
|
@@ -55,67 +52,64 @@ async function getDatasourceInfo({
|
|
|
55
52
|
configDir: void 0
|
|
56
53
|
};
|
|
57
54
|
}
|
|
58
|
-
const prettyProvider = prettifyProvider(
|
|
59
|
-
const url = (0, import_internals.getEffectiveUrl)(
|
|
60
|
-
if (!url ||
|
|
55
|
+
const prettyProvider = prettifyProvider(datasource.provider);
|
|
56
|
+
const url = (0, import_internals.getEffectiveUrl)(datasource).value;
|
|
57
|
+
if (!url || datasource.provider === "sqlserver") {
|
|
61
58
|
return {
|
|
62
|
-
name:
|
|
59
|
+
name: datasource.name,
|
|
63
60
|
prettyProvider,
|
|
64
61
|
dbName: void 0,
|
|
65
62
|
dbLocation: void 0,
|
|
66
63
|
url: url || void 0,
|
|
67
64
|
schema: void 0,
|
|
68
|
-
schemas:
|
|
69
|
-
configDir: (
|
|
65
|
+
schemas: datasource.schemas,
|
|
66
|
+
configDir: import_path.default.dirname(datasource.sourceFilePath)
|
|
70
67
|
};
|
|
71
68
|
}
|
|
72
69
|
try {
|
|
73
70
|
const credentials = (0, import_internals.uriToCredentials)(url);
|
|
74
71
|
const dbLocation = getDbLocation(credentials);
|
|
75
|
-
let
|
|
76
|
-
if (["postgresql", "cockroachdb"].includes(
|
|
72
|
+
let schema = void 0;
|
|
73
|
+
if (["postgresql", "cockroachdb"].includes(datasource.provider)) {
|
|
77
74
|
if (credentials.schema) {
|
|
78
|
-
|
|
75
|
+
schema = credentials.schema;
|
|
79
76
|
} else {
|
|
80
|
-
|
|
77
|
+
schema = "public";
|
|
81
78
|
}
|
|
82
79
|
}
|
|
83
80
|
const datasourceInfo = {
|
|
84
|
-
name:
|
|
81
|
+
name: datasource.name,
|
|
85
82
|
prettyProvider,
|
|
86
83
|
dbName: credentials.database,
|
|
87
84
|
dbLocation,
|
|
88
85
|
url,
|
|
89
|
-
schema
|
|
90
|
-
schemas:
|
|
91
|
-
configDir: (
|
|
86
|
+
schema,
|
|
87
|
+
schemas: datasource.schemas,
|
|
88
|
+
configDir: import_path.default.dirname(datasource.sourceFilePath)
|
|
92
89
|
};
|
|
93
|
-
if (
|
|
90
|
+
if (datasource.provider === "postgresql" && datasourceInfo.dbName === void 0) {
|
|
94
91
|
datasourceInfo.dbName = "postgres";
|
|
95
92
|
}
|
|
96
93
|
return datasourceInfo;
|
|
97
94
|
} catch (e) {
|
|
98
95
|
return {
|
|
99
|
-
name:
|
|
96
|
+
name: datasource.name,
|
|
100
97
|
prettyProvider,
|
|
101
98
|
dbName: void 0,
|
|
102
99
|
dbLocation: void 0,
|
|
103
100
|
url,
|
|
104
101
|
schema: void 0,
|
|
105
|
-
schemas:
|
|
106
|
-
configDir: (
|
|
102
|
+
schemas: datasource.schemas,
|
|
103
|
+
configDir: import_path.default.dirname(datasource.sourceFilePath)
|
|
107
104
|
};
|
|
108
105
|
}
|
|
109
106
|
}
|
|
110
|
-
async function ensureCanConnectToDatabase(
|
|
111
|
-
|
|
112
|
-
const config = await (0, import_internals.getConfig)({ datamodel: schema, ignoreEnvVarErrors: false });
|
|
113
|
-
const firstDatasource = config.datasources[0] ? config.datasources[0] : void 0;
|
|
114
|
-
if (!firstDatasource) {
|
|
107
|
+
async function ensureCanConnectToDatabase(datasource) {
|
|
108
|
+
if (!datasource) {
|
|
115
109
|
throw new Error(`A datasource block is missing in the Prisma schema file.`);
|
|
116
110
|
}
|
|
117
|
-
const schemaDir = (
|
|
118
|
-
const url = (
|
|
111
|
+
const schemaDir = import_path.default.dirname(datasource.sourceFilePath);
|
|
112
|
+
const url = getConnectionUrl(datasource);
|
|
119
113
|
const canConnect = await (0, import_internals.canConnectToDatabase)(url, schemaDir);
|
|
120
114
|
if (canConnect === true) {
|
|
121
115
|
return true;
|
|
@@ -124,15 +118,12 @@ async function ensureCanConnectToDatabase(schemaPath) {
|
|
|
124
118
|
throw new Error(`${code}: ${message}`);
|
|
125
119
|
}
|
|
126
120
|
}
|
|
127
|
-
async function ensureDatabaseExists(
|
|
128
|
-
|
|
129
|
-
const config = await (0, import_internals.getConfig)({ datamodel: schemas, ignoreEnvVarErrors: false });
|
|
130
|
-
const firstDatasource = config.datasources[0] ? config.datasources[0] : void 0;
|
|
131
|
-
if (!firstDatasource) {
|
|
121
|
+
async function ensureDatabaseExists(datasource) {
|
|
122
|
+
if (!datasource) {
|
|
132
123
|
throw new Error(`A datasource block is missing in the Prisma schema file.`);
|
|
133
124
|
}
|
|
134
|
-
const schemaDir = (
|
|
135
|
-
const url = (
|
|
125
|
+
const schemaDir = import_path.default.dirname(datasource.sourceFilePath);
|
|
126
|
+
const url = getConnectionUrl(datasource);
|
|
136
127
|
const canConnect = await (0, import_internals.canConnectToDatabase)(url, schemaDir);
|
|
137
128
|
if (canConnect === true) {
|
|
138
129
|
return;
|
|
@@ -141,16 +132,13 @@ async function ensureDatabaseExists(action, schemaPath) {
|
|
|
141
132
|
if (code !== "P1003") {
|
|
142
133
|
throw new Error(`${code}: ${message}`);
|
|
143
134
|
}
|
|
144
|
-
if (!schemaDir) {
|
|
145
|
-
throw new Error(`Could not locate ${schemaPath || "schema.prisma"}`);
|
|
146
|
-
}
|
|
147
135
|
if (await (0, import_internals.createDatabase)(url, schemaDir)) {
|
|
148
|
-
if (
|
|
136
|
+
if (datasource.provider === "sqlserver") {
|
|
149
137
|
return `SQL Server database created.
|
|
150
138
|
`;
|
|
151
139
|
}
|
|
152
140
|
const credentials = (0, import_internals.uriToCredentials)(url);
|
|
153
|
-
const prettyProvider = prettifyProvider(
|
|
141
|
+
const prettyProvider = prettifyProvider(datasource.provider);
|
|
154
142
|
let message2 = `${prettyProvider} database${credentials.database ? ` ${credentials.database} ` : " "}created`;
|
|
155
143
|
const dbLocation = getDbLocation(credentials);
|
|
156
144
|
if (dbLocation) {
|
|
@@ -193,3 +181,14 @@ function prettifyProvider(provider) {
|
|
|
193
181
|
return `MongoDB`;
|
|
194
182
|
}
|
|
195
183
|
}
|
|
184
|
+
function getConnectionUrl(datasource) {
|
|
185
|
+
const url = (0, import_internals.getEffectiveUrl)(datasource);
|
|
186
|
+
if (!url.value) {
|
|
187
|
+
if (url.fromEnvVar) {
|
|
188
|
+
throw new Error(`Environment variable '${url.fromEnvVar}' with database connection URL was not found.`);
|
|
189
|
+
} else {
|
|
190
|
+
throw new Error(`Datasource is missing a database connection URL.`);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return url.value;
|
|
194
|
+
}
|
|
@@ -16,15 +16,15 @@ 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
|
|
20
|
-
__export(
|
|
19
|
+
var chunk_AI6DH66U_exports = {};
|
|
20
|
+
__export(chunk_AI6DH66U_exports, {
|
|
21
21
|
printDatamodelObject: () => printDatamodelObject,
|
|
22
22
|
printDatasources: () => printDatasources
|
|
23
23
|
});
|
|
24
|
-
module.exports = __toCommonJS(
|
|
25
|
-
var
|
|
26
|
-
var
|
|
27
|
-
var import_indent_string = (0,
|
|
24
|
+
module.exports = __toCommonJS(chunk_AI6DH66U_exports);
|
|
25
|
+
var import_chunk_2R6DII47 = require("./chunk-2R6DII47.js");
|
|
26
|
+
var import_chunk_2ESYSVXG = require("./chunk-2ESYSVXG.js");
|
|
27
|
+
var import_indent_string = (0, import_chunk_2ESYSVXG.__toESM)((0, import_chunk_2R6DII47.require_indent_string)());
|
|
28
28
|
function printDatasources(internalDatasources) {
|
|
29
29
|
return internalDatasources.map((d) => String(new InternalDataSourceClass(d))).join("\n\n");
|
|
30
30
|
}
|
|
@@ -16,16 +16,16 @@ 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
|
|
20
|
-
__export(
|
|
19
|
+
var chunk_B4SUSDC2_exports = {};
|
|
20
|
+
__export(chunk_B4SUSDC2_exports, {
|
|
21
21
|
DbSeed: () => DbSeed
|
|
22
22
|
});
|
|
23
|
-
module.exports = __toCommonJS(
|
|
24
|
-
var
|
|
23
|
+
module.exports = __toCommonJS(chunk_B4SUSDC2_exports);
|
|
24
|
+
var import_chunk_5LKIRKDL = require("./chunk-5LKIRKDL.js");
|
|
25
25
|
var import_chunk_SKRR5WT4 = require("./chunk-SKRR5WT4.js");
|
|
26
|
-
var
|
|
26
|
+
var import_chunk_2ESYSVXG = require("./chunk-2ESYSVXG.js");
|
|
27
27
|
var import_internals = require("@prisma/internals");
|
|
28
|
-
var require_arg = (0,
|
|
28
|
+
var require_arg = (0, import_chunk_2ESYSVXG.__commonJS)({
|
|
29
29
|
"../../node_modules/.pnpm/arg@5.0.2/node_modules/arg/index.js"(exports, module2) {
|
|
30
30
|
"use strict";
|
|
31
31
|
var flagSymbol = Symbol("arg flag");
|
|
@@ -168,11 +168,28 @@ var require_arg = (0, import_chunk_WWAWV7DQ.__commonJS)({
|
|
|
168
168
|
module2.exports = arg2;
|
|
169
169
|
}
|
|
170
170
|
});
|
|
171
|
-
var import_arg = (0,
|
|
172
|
-
var
|
|
171
|
+
var import_arg = (0, import_chunk_2ESYSVXG.__toESM)(require_arg());
|
|
172
|
+
var DbSeed = class _DbSeed {
|
|
173
173
|
static new() {
|
|
174
|
-
return new
|
|
174
|
+
return new _DbSeed();
|
|
175
175
|
}
|
|
176
|
+
static help = (0, import_internals.format)(`
|
|
177
|
+
${process.platform === "win32" ? "" : "\u{1F64C} "}Seed your database
|
|
178
|
+
|
|
179
|
+
${(0, import_chunk_SKRR5WT4.bold)("Usage")}
|
|
180
|
+
|
|
181
|
+
${(0, import_chunk_SKRR5WT4.dim)("$")} prisma db seed [options]
|
|
182
|
+
|
|
183
|
+
${(0, import_chunk_SKRR5WT4.bold)("Options")}
|
|
184
|
+
|
|
185
|
+
-h, --help Display this help message
|
|
186
|
+
--config Custom path to your Prisma config file
|
|
187
|
+
|
|
188
|
+
${(0, import_chunk_SKRR5WT4.bold)("Examples")}
|
|
189
|
+
|
|
190
|
+
Passing extra arguments to the seed command
|
|
191
|
+
${(0, import_chunk_SKRR5WT4.dim)("$")} prisma db seed -- --arg1 value1 --arg2 value2
|
|
192
|
+
`);
|
|
176
193
|
async parse(argv, config) {
|
|
177
194
|
const args = (0, import_internals.arg)(
|
|
178
195
|
argv,
|
|
@@ -197,17 +214,10 @@ ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma db seed -- --arg1 value1 --arg2 va
|
|
|
197
214
|
return this.help();
|
|
198
215
|
}
|
|
199
216
|
await (0, import_internals.loadEnvFile)({ schemaPath: args["--schema"], printMessage: true, config });
|
|
200
|
-
const seedCommandFromPkgJson = await (0,
|
|
201
|
-
if (!seedCommandFromPkgJson)
|
|
202
|
-
const schemaResult = await (0, import_internals.getSchemaWithPath)(args["--schema"], config.schema);
|
|
203
|
-
const message = await (0, import_chunk_V3ZMNXZC.verifySeedConfigAndReturnMessage)(schemaResult?.schemaPath ?? null);
|
|
204
|
-
if (message) {
|
|
205
|
-
throw new Error(message);
|
|
206
|
-
}
|
|
207
|
-
return ``;
|
|
208
|
-
}
|
|
217
|
+
const seedCommandFromPkgJson = await (0, import_chunk_5LKIRKDL.getSeedCommandFromPackageJson)(process.cwd());
|
|
218
|
+
if (!seedCommandFromPkgJson) return ``;
|
|
209
219
|
const extraArgs = args._.join(" ");
|
|
210
|
-
const successfulSeeding = await (0,
|
|
220
|
+
const successfulSeeding = await (0, import_chunk_5LKIRKDL.executeSeedCommand)({ commandFromConfig: seedCommandFromPkgJson, extraArgs });
|
|
211
221
|
if (successfulSeeding) {
|
|
212
222
|
return `
|
|
213
223
|
${process.platform === "win32" ? "" : "\u{1F331} "}The seed command has been executed.`;
|
|
@@ -219,26 +229,8 @@ ${process.platform === "win32" ? "" : "\u{1F331} "}The seed command has been ex
|
|
|
219
229
|
if (error) {
|
|
220
230
|
return new import_internals.HelpError(`
|
|
221
231
|
${(0, import_chunk_SKRR5WT4.bold)((0, import_chunk_SKRR5WT4.red)(`!`))} ${error}
|
|
222
|
-
${
|
|
232
|
+
${_DbSeed.help}`);
|
|
223
233
|
}
|
|
224
|
-
return
|
|
234
|
+
return _DbSeed.help;
|
|
225
235
|
}
|
|
226
236
|
};
|
|
227
|
-
(0, import_chunk_WWAWV7DQ.__publicField)(_DbSeed, "help", (0, import_internals.format)(`
|
|
228
|
-
${process.platform === "win32" ? "" : "\u{1F64C} "}Seed your database
|
|
229
|
-
|
|
230
|
-
${(0, import_chunk_SKRR5WT4.bold)("Usage")}
|
|
231
|
-
|
|
232
|
-
${(0, import_chunk_SKRR5WT4.dim)("$")} prisma db seed [options]
|
|
233
|
-
|
|
234
|
-
${(0, import_chunk_SKRR5WT4.bold)("Options")}
|
|
235
|
-
|
|
236
|
-
-h, --help Display this help message
|
|
237
|
-
--config Custom path to your Prisma config file
|
|
238
|
-
|
|
239
|
-
${(0, import_chunk_SKRR5WT4.bold)("Examples")}
|
|
240
|
-
|
|
241
|
-
Passing extra arguments to the seed command
|
|
242
|
-
${(0, import_chunk_SKRR5WT4.dim)("$")} prisma db seed -- --arg1 value1 --arg2 value2
|
|
243
|
-
`));
|
|
244
|
-
var DbSeed = _DbSeed;
|
|
@@ -26,31 +26,58 @@ 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
|
|
30
|
-
__export(
|
|
29
|
+
var chunk_CKRN45WP_exports = {};
|
|
30
|
+
__export(chunk_CKRN45WP_exports, {
|
|
31
31
|
MigrateDev: () => MigrateDev
|
|
32
32
|
});
|
|
33
|
-
module.exports = __toCommonJS(
|
|
34
|
-
var
|
|
33
|
+
module.exports = __toCommonJS(chunk_CKRN45WP_exports);
|
|
34
|
+
var import_chunk_YBX7R3MT = require("./chunk-YBX7R3MT.js");
|
|
35
35
|
var import_chunk_7CQBDP4H = require("./chunk-7CQBDP4H.js");
|
|
36
|
-
var
|
|
37
|
-
var
|
|
36
|
+
var import_chunk_5LKIRKDL = require("./chunk-5LKIRKDL.js");
|
|
37
|
+
var import_chunk_KRQEFTDT = require("./chunk-KRQEFTDT.js");
|
|
38
38
|
var import_chunk_UP6FVCDK = require("./chunk-UP6FVCDK.js");
|
|
39
|
-
var
|
|
39
|
+
var import_chunk_PDCXVUV3 = require("./chunk-PDCXVUV3.js");
|
|
40
40
|
var import_chunk_3WC4XD74 = require("./chunk-3WC4XD74.js");
|
|
41
|
-
var import_chunk_GKDFIHM2 = require("./chunk-GKDFIHM2.js");
|
|
42
41
|
var import_chunk_QOPTDDIH = require("./chunk-QOPTDDIH.js");
|
|
43
|
-
var
|
|
42
|
+
var import_chunk_74LUB4XX = require("./chunk-74LUB4XX.js");
|
|
44
43
|
var import_chunk_SKRR5WT4 = require("./chunk-SKRR5WT4.js");
|
|
45
|
-
var import_chunk_WWAWV7DQ = require("./chunk-WWAWV7DQ.js");
|
|
46
44
|
var import_debug = __toESM(require("@prisma/debug"));
|
|
47
45
|
var import_internals = require("@prisma/internals");
|
|
48
46
|
var import_prompts = __toESM(require("prompts"));
|
|
49
47
|
var debug = (0, import_debug.default)("prisma:migrate:dev");
|
|
50
|
-
var
|
|
48
|
+
var MigrateDev = class _MigrateDev {
|
|
51
49
|
static new() {
|
|
52
|
-
return new
|
|
50
|
+
return new _MigrateDev();
|
|
53
51
|
}
|
|
52
|
+
static help = (0, import_internals.format)(`
|
|
53
|
+
${process.platform === "win32" ? "" : "\u{1F3CB}\uFE0F "}Create a migration from changes in Prisma schema, apply it to the database, trigger generators (e.g. Prisma Client)
|
|
54
|
+
|
|
55
|
+
${(0, import_chunk_SKRR5WT4.bold)("Usage")}
|
|
56
|
+
|
|
57
|
+
${(0, import_chunk_SKRR5WT4.dim)("$")} prisma migrate dev [options]
|
|
58
|
+
|
|
59
|
+
${(0, import_chunk_SKRR5WT4.bold)("Options")}
|
|
60
|
+
|
|
61
|
+
-h, --help Display this help message
|
|
62
|
+
--config Custom path to your Prisma config file
|
|
63
|
+
--schema Custom path to your Prisma schema
|
|
64
|
+
-n, --name Name the migration
|
|
65
|
+
--create-only Create a new migration but do not apply it
|
|
66
|
+
The migration will be empty if there are no changes in Prisma schema
|
|
67
|
+
--skip-generate Skip triggering generators (e.g. Prisma Client)
|
|
68
|
+
--skip-seed Skip triggering seed
|
|
69
|
+
|
|
70
|
+
${(0, import_chunk_SKRR5WT4.bold)("Examples")}
|
|
71
|
+
|
|
72
|
+
Create a migration from changes in Prisma schema, apply it to the database, trigger generators (e.g. Prisma Client)
|
|
73
|
+
${(0, import_chunk_SKRR5WT4.dim)("$")} prisma migrate dev
|
|
74
|
+
|
|
75
|
+
Specify a schema
|
|
76
|
+
${(0, import_chunk_SKRR5WT4.dim)("$")} prisma migrate dev --schema=./schema.prisma
|
|
77
|
+
|
|
78
|
+
Create a migration without applying it
|
|
79
|
+
${(0, import_chunk_SKRR5WT4.dim)("$")} prisma migrate dev --create-only
|
|
80
|
+
`);
|
|
54
81
|
async parse(argv, config) {
|
|
55
82
|
const args = (0, import_internals.arg)(argv, {
|
|
56
83
|
"--help": Boolean,
|
|
@@ -69,27 +96,25 @@ var _MigrateDev = class _MigrateDev2 {
|
|
|
69
96
|
if ((0, import_internals.isError)(args)) {
|
|
70
97
|
return this.help(args.message);
|
|
71
98
|
}
|
|
72
|
-
await (0, import_internals.checkUnsupportedDataProxy)("migrate dev", args, config.schema, true);
|
|
73
99
|
if (args["--help"]) {
|
|
74
100
|
return this.help();
|
|
75
101
|
}
|
|
76
102
|
await (0, import_internals.loadEnvFile)({ schemaPath: args["--schema"], printMessage: true, config });
|
|
77
|
-
const
|
|
78
|
-
|
|
103
|
+
const schemaContext = await (0, import_internals.loadSchemaContext)({
|
|
104
|
+
schemaPathFromArg: args["--schema"],
|
|
105
|
+
schemaPathFromConfig: config.schema
|
|
106
|
+
});
|
|
107
|
+
const { migrationsDirPath } = (0, import_internals.inferDirectoryConfig)(schemaContext);
|
|
108
|
+
(0, import_internals.checkUnsupportedDataProxy)({ cmd: "migrate dev", schemaContext });
|
|
109
|
+
const datasourceInfo = (0, import_chunk_74LUB4XX.parseDatasourceInfo)(schemaContext.primaryDatasource);
|
|
79
110
|
(0, import_chunk_QOPTDDIH.printDatasource)({ datasourceInfo });
|
|
80
111
|
process.stdout.write("\n");
|
|
81
|
-
(0, import_internals.validate)({
|
|
82
|
-
|
|
83
|
-
});
|
|
84
|
-
await (0, import_internals.getConfig)({
|
|
85
|
-
datamodel: schemas,
|
|
86
|
-
ignoreEnvVarErrors: false
|
|
87
|
-
});
|
|
88
|
-
const wasDbCreated = await (0, import_chunk_DJMFXNR4.ensureDatabaseExists)("create", schemaPath);
|
|
112
|
+
(0, import_internals.validate)({ schemas: schemaContext.schemaFiles });
|
|
113
|
+
const wasDbCreated = await (0, import_chunk_74LUB4XX.ensureDatabaseExists)(schemaContext.primaryDatasource);
|
|
89
114
|
if (wasDbCreated) {
|
|
90
115
|
process.stdout.write(wasDbCreated + "\n\n");
|
|
91
116
|
}
|
|
92
|
-
const migrate = new
|
|
117
|
+
const migrate = new import_chunk_PDCXVUV3.Migrate(schemaContext, migrationsDirPath);
|
|
93
118
|
let devDiagnostic;
|
|
94
119
|
try {
|
|
95
120
|
devDiagnostic = await migrate.devDiagnostic();
|
|
@@ -121,7 +146,7 @@ ${(0, import_chunk_SKRR5WT4.bold)((0, import_chunk_SKRR5WT4.red)("All data will
|
|
|
121
146
|
`
|
|
122
147
|
The following migration(s) have been applied:
|
|
123
148
|
|
|
124
|
-
${(0,
|
|
149
|
+
${(0, import_chunk_KRQEFTDT.printFilesFromMigrationIds)(
|
|
125
150
|
"migrations",
|
|
126
151
|
appliedMigrationNames,
|
|
127
152
|
{
|
|
@@ -181,7 +206,7 @@ ${(0, import_chunk_255BRND3.printFilesFromMigrationIds)(
|
|
|
181
206
|
}
|
|
182
207
|
let migrationName = void 0;
|
|
183
208
|
if (evaluateDataLossResult.migrationSteps > 0 || args["--create-only"]) {
|
|
184
|
-
const getMigrationNameResult = await (0,
|
|
209
|
+
const getMigrationNameResult = await (0, import_chunk_YBX7R3MT.getMigrationName)(args["--name"]);
|
|
185
210
|
if (getMigrationNameResult.userCancelled) {
|
|
186
211
|
process.stdout.write(getMigrationNameResult.userCancelled + "\n");
|
|
187
212
|
migrate.stop();
|
|
@@ -193,10 +218,9 @@ ${(0, import_chunk_255BRND3.printFilesFromMigrationIds)(
|
|
|
193
218
|
let migrationIds;
|
|
194
219
|
try {
|
|
195
220
|
const createMigrationResult = await migrate.createMigration({
|
|
196
|
-
migrationsDirectoryPath: migrate.migrationsDirectoryPath,
|
|
197
221
|
migrationName: migrationName || "",
|
|
198
222
|
draft: args["--create-only"] ? true : false,
|
|
199
|
-
schema:
|
|
223
|
+
schema: migrate.getPrismaSchema()
|
|
200
224
|
});
|
|
201
225
|
debug({ createMigrationResult });
|
|
202
226
|
if (args["--create-only"]) {
|
|
@@ -226,7 +250,7 @@ You can now edit it and apply it by running ${(0, import_chunk_SKRR5WT4.green)((
|
|
|
226
250
|
`
|
|
227
251
|
The following migration(s) have been created and applied from new schema changes:
|
|
228
252
|
|
|
229
|
-
${(0,
|
|
253
|
+
${(0, import_chunk_KRQEFTDT.printFilesFromMigrationIds)(
|
|
230
254
|
"migrations",
|
|
231
255
|
migrationIds,
|
|
232
256
|
{
|
|
@@ -244,10 +268,10 @@ ${(0, import_chunk_SKRR5WT4.green)("Your database is now in sync with your schem
|
|
|
244
268
|
}
|
|
245
269
|
if (wasDbCreated && !process.env.PRISMA_MIGRATE_SKIP_SEED && !args["--skip-seed"]) {
|
|
246
270
|
try {
|
|
247
|
-
const seedCommandFromPkgJson = await (0,
|
|
271
|
+
const seedCommandFromPkgJson = await (0, import_chunk_5LKIRKDL.getSeedCommandFromPackageJson)(process.cwd());
|
|
248
272
|
if (seedCommandFromPkgJson) {
|
|
249
273
|
process.stdout.write("\n");
|
|
250
|
-
const successfulSeeding = await (0,
|
|
274
|
+
const successfulSeeding = await (0, import_chunk_5LKIRKDL.executeSeedCommand)({ commandFromConfig: seedCommandFromPkgJson });
|
|
251
275
|
if (successfulSeeding) {
|
|
252
276
|
process.stdout.write(`
|
|
253
277
|
${process.platform === "win32" ? "" : "\u{1F331} "}The seed command has been executed.
|
|
@@ -255,9 +279,6 @@ ${process.platform === "win32" ? "" : "\u{1F331} "}The seed command has been ex
|
|
|
255
279
|
} else {
|
|
256
280
|
process.exit(1);
|
|
257
281
|
}
|
|
258
|
-
} else {
|
|
259
|
-
const { schemaPath: schemaPath2 } = await (0, import_internals.getSchemaWithPath)(args["--schema"], config.schema);
|
|
260
|
-
await (0, import_chunk_V3ZMNXZC.verifySeedConfigAndReturnMessage)(schemaPath2);
|
|
261
282
|
}
|
|
262
283
|
} catch (e) {
|
|
263
284
|
console.error(e);
|
|
@@ -289,38 +310,8 @@ ${process.platform === "win32" ? "" : "\u{1F331} "}The seed command has been ex
|
|
|
289
310
|
if (error) {
|
|
290
311
|
return new import_internals.HelpError(`
|
|
291
312
|
${(0, import_chunk_SKRR5WT4.bold)((0, import_chunk_SKRR5WT4.red)(`!`))} ${error}
|
|
292
|
-
${
|
|
313
|
+
${_MigrateDev.help}`);
|
|
293
314
|
}
|
|
294
|
-
return
|
|
315
|
+
return _MigrateDev.help;
|
|
295
316
|
}
|
|
296
317
|
};
|
|
297
|
-
(0, import_chunk_WWAWV7DQ.__publicField)(_MigrateDev, "help", (0, import_internals.format)(`
|
|
298
|
-
${process.platform === "win32" ? "" : "\u{1F3CB}\uFE0F "}Create a migration from changes in Prisma schema, apply it to the database, trigger generators (e.g. Prisma Client)
|
|
299
|
-
|
|
300
|
-
${(0, import_chunk_SKRR5WT4.bold)("Usage")}
|
|
301
|
-
|
|
302
|
-
${(0, import_chunk_SKRR5WT4.dim)("$")} prisma migrate dev [options]
|
|
303
|
-
|
|
304
|
-
${(0, import_chunk_SKRR5WT4.bold)("Options")}
|
|
305
|
-
|
|
306
|
-
-h, --help Display this help message
|
|
307
|
-
--config Custom path to your Prisma config file
|
|
308
|
-
--schema Custom path to your Prisma schema
|
|
309
|
-
-n, --name Name the migration
|
|
310
|
-
--create-only Create a new migration but do not apply it
|
|
311
|
-
The migration will be empty if there are no changes in Prisma schema
|
|
312
|
-
--skip-generate Skip triggering generators (e.g. Prisma Client)
|
|
313
|
-
--skip-seed Skip triggering seed
|
|
314
|
-
|
|
315
|
-
${(0, import_chunk_SKRR5WT4.bold)("Examples")}
|
|
316
|
-
|
|
317
|
-
Create a migration from changes in Prisma schema, apply it to the database, trigger generators (e.g. Prisma Client)
|
|
318
|
-
${(0, import_chunk_SKRR5WT4.dim)("$")} prisma migrate dev
|
|
319
|
-
|
|
320
|
-
Specify a schema
|
|
321
|
-
${(0, import_chunk_SKRR5WT4.dim)("$")} prisma migrate dev --schema=./schema.prisma
|
|
322
|
-
|
|
323
|
-
Create a migration without applying it
|
|
324
|
-
${(0, import_chunk_SKRR5WT4.dim)("$")} prisma migrate dev --create-only
|
|
325
|
-
`));
|
|
326
|
-
var MigrateDev = _MigrateDev;
|