@prisma/migrate 6.6.0-dev.27 → 6.6.0-dev.29
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/Migrate.js +5 -3
- package/dist/SchemaEngine.js +3 -3
- package/dist/bin.js +29 -28
- package/dist/chunk-23DZXSTI.js +62 -0
- package/dist/{chunk-VVP3QZ7Q.js → chunk-5Q5BJS5B.js} +63 -20
- package/dist/{chunk-YBNDKPPO.js → chunk-63ZT25OL.js} +12 -10
- package/dist/{chunk-DJMFXNR4.js → chunk-74LUB4XX.js} +56 -57
- package/dist/{chunk-IWC5MH4R.js → chunk-ABQZ5J74.js} +5 -5
- package/dist/{chunk-324Z6HS7.js → chunk-AM7BRZFD.js} +12 -10
- package/dist/{chunk-HJFSTAJX.js → chunk-BUAYZ4KA.js} +12 -10
- package/dist/{chunk-K43RXWQY.js → chunk-GHZAN2PG.js} +3 -9
- package/dist/{chunk-ZGR2WQ62.js → chunk-HPT54KSO.js} +9 -7
- package/dist/{chunk-KMHFSDY6.js → chunk-HQJ7FIWN.js} +14 -12
- package/dist/{chunk-GPNGRJAR.js → chunk-IRYXRMQC.js} +12 -10
- package/dist/{chunk-FBWTUBJC.js → chunk-LAEOX7QH.js} +12 -8
- package/dist/{chunk-MKS2ZJJ5.js → chunk-MTJFLQI4.js} +5 -5
- package/dist/{chunk-NJYZPNB4.js → chunk-SCH55BRJ.js} +36 -37
- package/dist/{chunk-DQMYH4YE.js → chunk-U6ZL4ORM.js} +10 -9
- package/dist/chunk-V6PVGSDJ.js +76 -0
- package/dist/{chunk-RI5NUPOB.js → chunk-WX6S3QMO.js} +11 -10
- package/dist/{chunk-BURHAP6O.js → chunk-ZCR4PTT3.js} +13 -18
- package/dist/commands/DbDrop.js +3 -4
- package/dist/commands/DbExecute.js +6 -4
- package/dist/commands/DbPull.js +6 -6
- package/dist/commands/DbPush.js +7 -6
- package/dist/commands/MigrateDeploy.js +7 -6
- package/dist/commands/MigrateDev.js +7 -6
- package/dist/commands/MigrateDiff.js +7 -5
- package/dist/commands/MigrateReset.js +7 -6
- package/dist/commands/MigrateResolve.js +7 -6
- package/dist/commands/MigrateStatus.js +7 -6
- package/dist/index.js +35 -33
- package/dist/internals/src/cli/schemaContext.d.ts +43 -0
- package/dist/internals/src/index.d.ts +1 -0
- package/dist/internals/src/migrateTypes.d.ts +63 -0
- package/dist/migrate/src/Migrate.d.ts +3 -1
- package/dist/migrate/src/SchemaEngine.d.ts +0 -4
- package/dist/migrate/src/types.d.ts +13 -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/listMigrations.d.ts +9 -0
- package/dist/utils/createMigration.js +27 -0
- package/dist/utils/ensureDatabaseExists.js +6 -6
- package/dist/utils/getDatabaseVersionSafe.js +3 -3
- package/dist/utils/introspectSql.js +3 -3
- package/dist/utils/listMigrations.js +25 -0
- package/dist/utils/setupMSSQL.js +1 -1
- package/package.json +7 -7
|
@@ -26,18 +26,17 @@ 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_AM7BRZFD_exports = {};
|
|
30
|
+
__export(chunk_AM7BRZFD_exports, {
|
|
31
31
|
MigrateReset: () => MigrateReset
|
|
32
32
|
});
|
|
33
|
-
module.exports = __toCommonJS(
|
|
33
|
+
module.exports = __toCommonJS(chunk_AM7BRZFD_exports);
|
|
34
34
|
var import_chunk_5LKIRKDL = require("./chunk-5LKIRKDL.js");
|
|
35
35
|
var import_chunk_KRQEFTDT = require("./chunk-KRQEFTDT.js");
|
|
36
|
-
var
|
|
36
|
+
var import_chunk_5Q5BJS5B = require("./chunk-5Q5BJS5B.js");
|
|
37
37
|
var import_chunk_3WC4XD74 = require("./chunk-3WC4XD74.js");
|
|
38
|
-
var import_chunk_GKDFIHM2 = require("./chunk-GKDFIHM2.js");
|
|
39
38
|
var import_chunk_QOPTDDIH = require("./chunk-QOPTDDIH.js");
|
|
40
|
-
var
|
|
39
|
+
var import_chunk_74LUB4XX = require("./chunk-74LUB4XX.js");
|
|
41
40
|
var import_chunk_SKRR5WT4 = require("./chunk-SKRR5WT4.js");
|
|
42
41
|
var import_internals = require("@prisma/internals");
|
|
43
42
|
var import_prompts = __toESM(require("prompts"));
|
|
@@ -92,10 +91,13 @@ ${(0, import_chunk_SKRR5WT4.bold)("Examples")}
|
|
|
92
91
|
return this.help();
|
|
93
92
|
}
|
|
94
93
|
await (0, import_internals.loadEnvFile)({ schemaPath: args["--schema"], printMessage: true, config });
|
|
95
|
-
const
|
|
96
|
-
|
|
94
|
+
const schemaContext = await (0, import_internals.loadSchemaContext)({
|
|
95
|
+
schemaPathFromArg: args["--schema"],
|
|
96
|
+
schemaPathFromConfig: config.schema
|
|
97
|
+
});
|
|
98
|
+
const datasourceInfo = (0, import_chunk_74LUB4XX.parseDatasourceInfo)(schemaContext.primaryDatasource);
|
|
97
99
|
(0, import_chunk_QOPTDDIH.printDatasource)({ datasourceInfo });
|
|
98
|
-
const wasDbCreated = await (0,
|
|
100
|
+
const wasDbCreated = await (0, import_chunk_74LUB4XX.ensureDatabaseExists)(schemaContext.primaryDatasource);
|
|
99
101
|
if (wasDbCreated) {
|
|
100
102
|
process.stdout.write("\n" + wasDbCreated + "\n");
|
|
101
103
|
}
|
|
@@ -115,7 +117,7 @@ ${(0, import_chunk_SKRR5WT4.bold)("Examples")}
|
|
|
115
117
|
process.exit(130);
|
|
116
118
|
}
|
|
117
119
|
}
|
|
118
|
-
const migrate = new
|
|
120
|
+
const migrate = new import_chunk_5Q5BJS5B.Migrate(schemaContext.schemaPath);
|
|
119
121
|
let migrationIds;
|
|
120
122
|
try {
|
|
121
123
|
await migrate.reset();
|
|
@@ -26,15 +26,14 @@ 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_BUAYZ4KA_exports = {};
|
|
30
|
+
__export(chunk_BUAYZ4KA_exports, {
|
|
31
31
|
MigrateStatus: () => MigrateStatus
|
|
32
32
|
});
|
|
33
|
-
module.exports = __toCommonJS(
|
|
34
|
-
var
|
|
35
|
-
var import_chunk_GKDFIHM2 = require("./chunk-GKDFIHM2.js");
|
|
33
|
+
module.exports = __toCommonJS(chunk_BUAYZ4KA_exports);
|
|
34
|
+
var import_chunk_5Q5BJS5B = require("./chunk-5Q5BJS5B.js");
|
|
36
35
|
var import_chunk_QOPTDDIH = require("./chunk-QOPTDDIH.js");
|
|
37
|
-
var
|
|
36
|
+
var import_chunk_74LUB4XX = require("./chunk-74LUB4XX.js");
|
|
38
37
|
var import_chunk_SKRR5WT4 = require("./chunk-SKRR5WT4.js");
|
|
39
38
|
var import_debug = __toESM(require("@prisma/debug"));
|
|
40
39
|
var import_internals = require("@prisma/internals");
|
|
@@ -84,10 +83,13 @@ Check the status of your database migrations
|
|
|
84
83
|
return this.help();
|
|
85
84
|
}
|
|
86
85
|
await (0, import_internals.loadEnvFile)({ schemaPath: args["--schema"], printMessage: true, config });
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
86
|
+
const schemaContext = await (0, import_internals.loadSchemaContext)({
|
|
87
|
+
schemaPathFromArg: args["--schema"],
|
|
88
|
+
schemaPathFromConfig: config.schema
|
|
89
|
+
});
|
|
90
|
+
(0, import_chunk_QOPTDDIH.printDatasource)({ datasourceInfo: (0, import_chunk_74LUB4XX.parseDatasourceInfo)(schemaContext.primaryDatasource) });
|
|
91
|
+
const migrate = new import_chunk_5Q5BJS5B.Migrate(schemaContext.schemaPath);
|
|
92
|
+
await (0, import_chunk_74LUB4XX.ensureCanConnectToDatabase)(schemaContext.primaryDatasource);
|
|
91
93
|
let diagnoseResult;
|
|
92
94
|
let listMigrationDirectoriesResult;
|
|
93
95
|
try {
|
|
@@ -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
|
|
30
|
-
__export(
|
|
29
|
+
var chunk_GHZAN2PG_exports = {};
|
|
30
|
+
__export(chunk_GHZAN2PG_exports, {
|
|
31
31
|
EngineError: () => EngineError,
|
|
32
32
|
SchemaEngine: () => SchemaEngine
|
|
33
33
|
});
|
|
34
|
-
module.exports = __toCommonJS(
|
|
34
|
+
module.exports = __toCommonJS(chunk_GHZAN2PG_exports);
|
|
35
35
|
var import_chunk_G7PJKEOV = require("./chunk-G7PJKEOV.js");
|
|
36
36
|
var import_chunk_L6KOIJJ5 = require("./chunk-L6KOIJJ5.js");
|
|
37
37
|
var import_chunk_SKRR5WT4 = require("./chunk-SKRR5WT4.js");
|
|
@@ -194,12 +194,6 @@ var SchemaEngine = class {
|
|
|
194
194
|
migrateDiff(args) {
|
|
195
195
|
return this.runCommand(this.getRPCPayload("diff", args));
|
|
196
196
|
}
|
|
197
|
-
/**
|
|
198
|
-
* List the names of the migrations in the migrations directory.
|
|
199
|
-
*/
|
|
200
|
-
listMigrationDirectories(args) {
|
|
201
|
-
return this.runCommand(this.getRPCPayload("listMigrationDirectories", args));
|
|
202
|
-
}
|
|
203
197
|
/**
|
|
204
198
|
* Mark a migration as applied in the migrations table.
|
|
205
199
|
* There are two possible outcomes:
|
|
@@ -26,16 +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
|
|
30
|
-
__export(
|
|
29
|
+
var chunk_HPT54KSO_exports = {};
|
|
30
|
+
__export(chunk_HPT54KSO_exports, {
|
|
31
31
|
DbDrop: () => DbDrop
|
|
32
32
|
});
|
|
33
|
-
module.exports = __toCommonJS(
|
|
33
|
+
module.exports = __toCommonJS(chunk_HPT54KSO_exports);
|
|
34
34
|
var import_chunk_IHDN3L3R = require("./chunk-IHDN3L3R.js");
|
|
35
35
|
var import_chunk_3WC4XD74 = require("./chunk-3WC4XD74.js");
|
|
36
|
-
var import_chunk_GKDFIHM2 = require("./chunk-GKDFIHM2.js");
|
|
37
36
|
var import_chunk_QOPTDDIH = require("./chunk-QOPTDDIH.js");
|
|
38
|
-
var
|
|
37
|
+
var import_chunk_74LUB4XX = require("./chunk-74LUB4XX.js");
|
|
39
38
|
var import_chunk_SKRR5WT4 = require("./chunk-SKRR5WT4.js");
|
|
40
39
|
var import_internals = require("@prisma/internals");
|
|
41
40
|
var import_prompts = __toESM(require("prompts"));
|
|
@@ -96,8 +95,11 @@ ${(0, import_chunk_SKRR5WT4.bold)("Examples")}
|
|
|
96
95
|
throw new import_chunk_IHDN3L3R.PreviewFlagError();
|
|
97
96
|
}
|
|
98
97
|
await (0, import_internals.loadEnvFile)({ schemaPath: args["--schema"], printMessage: true, config });
|
|
99
|
-
const {
|
|
100
|
-
|
|
98
|
+
const { primaryDatasource } = await (0, import_internals.loadSchemaContext)({
|
|
99
|
+
schemaPathFromArg: args["--schema"],
|
|
100
|
+
schemaPathFromConfig: config.schema
|
|
101
|
+
});
|
|
102
|
+
const datasourceInfo = (0, import_chunk_74LUB4XX.parseDatasourceInfo)(primaryDatasource);
|
|
101
103
|
(0, import_chunk_QOPTDDIH.printDatasource)({ datasourceInfo });
|
|
102
104
|
process.stdout.write("\n");
|
|
103
105
|
if (!args["--force"]) {
|
|
@@ -16,15 +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
|
|
20
|
-
__export(
|
|
19
|
+
var chunk_HQJ7FIWN_exports = {};
|
|
20
|
+
__export(chunk_HQJ7FIWN_exports, {
|
|
21
21
|
MigrateResolve: () => MigrateResolve
|
|
22
22
|
});
|
|
23
|
-
module.exports = __toCommonJS(
|
|
24
|
-
var
|
|
25
|
-
var import_chunk_GKDFIHM2 = require("./chunk-GKDFIHM2.js");
|
|
23
|
+
module.exports = __toCommonJS(chunk_HQJ7FIWN_exports);
|
|
24
|
+
var import_chunk_5Q5BJS5B = require("./chunk-5Q5BJS5B.js");
|
|
26
25
|
var import_chunk_QOPTDDIH = require("./chunk-QOPTDDIH.js");
|
|
27
|
-
var
|
|
26
|
+
var import_chunk_74LUB4XX = require("./chunk-74LUB4XX.js");
|
|
28
27
|
var import_chunk_SKRR5WT4 = require("./chunk-SKRR5WT4.js");
|
|
29
28
|
var import_internals = require("@prisma/internals");
|
|
30
29
|
var MigrateResolve = class _MigrateResolve {
|
|
@@ -86,8 +85,11 @@ ${(0, import_chunk_SKRR5WT4.bold)("Examples")}
|
|
|
86
85
|
return this.help();
|
|
87
86
|
}
|
|
88
87
|
await (0, import_internals.loadEnvFile)({ schemaPath: args["--schema"], printMessage: true, config });
|
|
89
|
-
const
|
|
90
|
-
|
|
88
|
+
const schemaContext = await (0, import_internals.loadSchemaContext)({
|
|
89
|
+
schemaPathFromArg: args["--schema"],
|
|
90
|
+
schemaPathFromConfig: config.schema
|
|
91
|
+
});
|
|
92
|
+
(0, import_chunk_QOPTDDIH.printDatasource)({ datasourceInfo: (0, import_chunk_74LUB4XX.parseDatasourceInfo)(schemaContext.primaryDatasource) });
|
|
91
93
|
if (!args["--applied"] && !args["--rolled-back"]) {
|
|
92
94
|
throw new Error(
|
|
93
95
|
`--applied or --rolled-back must be part of the command like:
|
|
@@ -105,8 +107,8 @@ ${(0, import_chunk_SKRR5WT4.bold)((0, import_chunk_SKRR5WT4.green)((0, import_in
|
|
|
105
107
|
)}`
|
|
106
108
|
);
|
|
107
109
|
}
|
|
108
|
-
await (0,
|
|
109
|
-
const migrate = new
|
|
110
|
+
await (0, import_chunk_74LUB4XX.ensureCanConnectToDatabase)(schemaContext.primaryDatasource);
|
|
111
|
+
const migrate = new import_chunk_5Q5BJS5B.Migrate(schemaContext.schemaPath);
|
|
110
112
|
try {
|
|
111
113
|
await migrate.markMigrationApplied({
|
|
112
114
|
migrationId: args["--applied"]
|
|
@@ -126,8 +128,8 @@ Migration ${args["--applied"]} marked as applied.
|
|
|
126
128
|
)}`
|
|
127
129
|
);
|
|
128
130
|
}
|
|
129
|
-
await (0,
|
|
130
|
-
const migrate = new
|
|
131
|
+
await (0, import_chunk_74LUB4XX.ensureCanConnectToDatabase)(schemaContext.primaryDatasource);
|
|
132
|
+
const migrate = new import_chunk_5Q5BJS5B.Migrate(schemaContext.schemaPath);
|
|
131
133
|
try {
|
|
132
134
|
await migrate.markMigrationRolledBack({
|
|
133
135
|
migrationId: args["--rolled-back"]
|
|
@@ -26,16 +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
|
|
30
|
-
__export(
|
|
29
|
+
var chunk_IRYXRMQC_exports = {};
|
|
30
|
+
__export(chunk_IRYXRMQC_exports, {
|
|
31
31
|
MigrateDeploy: () => MigrateDeploy
|
|
32
32
|
});
|
|
33
|
-
module.exports = __toCommonJS(
|
|
33
|
+
module.exports = __toCommonJS(chunk_IRYXRMQC_exports);
|
|
34
34
|
var import_chunk_KRQEFTDT = require("./chunk-KRQEFTDT.js");
|
|
35
|
-
var
|
|
36
|
-
var import_chunk_GKDFIHM2 = require("./chunk-GKDFIHM2.js");
|
|
35
|
+
var import_chunk_5Q5BJS5B = require("./chunk-5Q5BJS5B.js");
|
|
37
36
|
var import_chunk_QOPTDDIH = require("./chunk-QOPTDDIH.js");
|
|
38
|
-
var
|
|
37
|
+
var import_chunk_74LUB4XX = require("./chunk-74LUB4XX.js");
|
|
39
38
|
var import_chunk_SKRR5WT4 = require("./chunk-SKRR5WT4.js");
|
|
40
39
|
var import_debug = __toESM(require("@prisma/debug"));
|
|
41
40
|
var import_internals = require("@prisma/internals");
|
|
@@ -86,11 +85,14 @@ ${(0, import_chunk_SKRR5WT4.bold)("Examples")}
|
|
|
86
85
|
return this.help();
|
|
87
86
|
}
|
|
88
87
|
await (0, import_internals.loadEnvFile)({ schemaPath: args["--schema"], printMessage: true, config });
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
88
|
+
const schemaContext = await (0, import_internals.loadSchemaContext)({
|
|
89
|
+
schemaPathFromArg: args["--schema"],
|
|
90
|
+
schemaPathFromConfig: config.schema
|
|
91
|
+
});
|
|
92
|
+
(0, import_chunk_QOPTDDIH.printDatasource)({ datasourceInfo: (0, import_chunk_74LUB4XX.parseDatasourceInfo)(schemaContext.primaryDatasource) });
|
|
93
|
+
const migrate = new import_chunk_5Q5BJS5B.Migrate(schemaContext.schemaPath);
|
|
92
94
|
try {
|
|
93
|
-
const wasDbCreated = await (0,
|
|
95
|
+
const wasDbCreated = await (0, import_chunk_74LUB4XX.ensureDatabaseExists)(schemaContext.primaryDatasource);
|
|
94
96
|
if (wasDbCreated) {
|
|
95
97
|
process.stdout.write("\n" + wasDbCreated + "\n");
|
|
96
98
|
}
|
|
@@ -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
|
|
30
|
-
__export(
|
|
29
|
+
var chunk_LAEOX7QH_exports = {};
|
|
30
|
+
__export(chunk_LAEOX7QH_exports, {
|
|
31
31
|
DbExecute: () => DbExecute
|
|
32
32
|
});
|
|
33
|
-
module.exports = __toCommonJS(
|
|
34
|
-
var
|
|
33
|
+
module.exports = __toCommonJS(chunk_LAEOX7QH_exports);
|
|
34
|
+
var import_chunk_5Q5BJS5B = require("./chunk-5Q5BJS5B.js");
|
|
35
35
|
var import_chunk_SKRR5WT4 = require("./chunk-SKRR5WT4.js");
|
|
36
36
|
var import_internals = require("@prisma/internals");
|
|
37
37
|
var import_fs = __toESM(require("fs"));
|
|
@@ -191,14 +191,18 @@ See \`${(0, import_chunk_SKRR5WT4.green)((0, import_internals.getCommandWithExec
|
|
|
191
191
|
url: args["--url"]
|
|
192
192
|
};
|
|
193
193
|
} else {
|
|
194
|
-
const
|
|
195
|
-
|
|
194
|
+
const schemaContext = await (0, import_internals.loadSchemaContext)({
|
|
195
|
+
schemaPathFromArg: args["--schema"],
|
|
196
|
+
schemaPathFromConfig: config.schema,
|
|
197
|
+
printLoadMessage: false
|
|
198
|
+
});
|
|
196
199
|
datasourceType = {
|
|
197
200
|
tag: "schema",
|
|
198
|
-
...(0, import_internals.
|
|
201
|
+
...(0, import_internals.toSchemasContainer)(schemaContext.schemaFiles),
|
|
202
|
+
configDir: schemaContext.primaryDatasourceDirectory
|
|
199
203
|
};
|
|
200
204
|
}
|
|
201
|
-
const migrate = new
|
|
205
|
+
const migrate = new import_chunk_5Q5BJS5B.Migrate();
|
|
202
206
|
try {
|
|
203
207
|
await migrate.engine.dbExecute({
|
|
204
208
|
script,
|
|
@@ -26,19 +26,19 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var
|
|
30
|
-
__export(
|
|
29
|
+
var chunk_MTJFLQI4_exports = {};
|
|
30
|
+
__export(chunk_MTJFLQI4_exports, {
|
|
31
31
|
getDatabaseVersionSafe: () => getDatabaseVersionSafe
|
|
32
32
|
});
|
|
33
|
-
module.exports = __toCommonJS(
|
|
34
|
-
var
|
|
33
|
+
module.exports = __toCommonJS(chunk_MTJFLQI4_exports);
|
|
34
|
+
var import_chunk_GHZAN2PG = require("./chunk-GHZAN2PG.js");
|
|
35
35
|
var import_debug = __toESM(require("@prisma/debug"));
|
|
36
36
|
var debug = (0, import_debug.default)("prisma:cli");
|
|
37
37
|
async function getDatabaseVersionSafe(args) {
|
|
38
38
|
let engine;
|
|
39
39
|
let dbVersion;
|
|
40
40
|
try {
|
|
41
|
-
engine = new
|
|
41
|
+
engine = new import_chunk_GHZAN2PG.SchemaEngine({});
|
|
42
42
|
dbVersion = await engine.getDatabaseVersion(args);
|
|
43
43
|
} catch (e) {
|
|
44
44
|
debug(e);
|
|
@@ -26,24 +26,24 @@ 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_SCH55BRJ_exports = {};
|
|
30
|
+
__export(chunk_SCH55BRJ_exports, {
|
|
31
31
|
DbPull: () => DbPull
|
|
32
32
|
});
|
|
33
|
-
module.exports = __toCommonJS(
|
|
33
|
+
module.exports = __toCommonJS(chunk_SCH55BRJ_exports);
|
|
34
34
|
var import_chunk_IINN7QUV = require("./chunk-IINN7QUV.js");
|
|
35
|
+
var import_chunk_JZ75RIMZ = require("./chunk-JZ75RIMZ.js");
|
|
36
|
+
var import_chunk_RR6BKMNO = require("./chunk-RR6BKMNO.js");
|
|
35
37
|
var import_chunk_RTGQXNX6 = require("./chunk-RTGQXNX6.js");
|
|
36
38
|
var import_chunk_AI6DH66U = require("./chunk-AI6DH66U.js");
|
|
37
39
|
var import_chunk_AHJ2N6BJ = require("./chunk-AHJ2N6BJ.js");
|
|
38
|
-
var import_chunk_JZ75RIMZ = require("./chunk-JZ75RIMZ.js");
|
|
39
|
-
var import_chunk_RR6BKMNO = require("./chunk-RR6BKMNO.js");
|
|
40
40
|
var import_chunk_JFKDSUIE = require("./chunk-JFKDSUIE.js");
|
|
41
41
|
var import_chunk_LGYRZ6CV = require("./chunk-LGYRZ6CV.js");
|
|
42
|
-
var
|
|
42
|
+
var import_chunk_GHZAN2PG = require("./chunk-GHZAN2PG.js");
|
|
43
43
|
var import_chunk_G7PJKEOV = require("./chunk-G7PJKEOV.js");
|
|
44
44
|
var import_chunk_3WC4XD74 = require("./chunk-3WC4XD74.js");
|
|
45
45
|
var import_chunk_QOPTDDIH = require("./chunk-QOPTDDIH.js");
|
|
46
|
-
var
|
|
46
|
+
var import_chunk_74LUB4XX = require("./chunk-74LUB4XX.js");
|
|
47
47
|
var import_chunk_SKRR5WT4 = require("./chunk-SKRR5WT4.js");
|
|
48
48
|
var import_debug = __toESM(require("@prisma/debug"));
|
|
49
49
|
var import_internals = require("@prisma/internals");
|
|
@@ -127,38 +127,38 @@ Set composite types introspection depth to 2 levels
|
|
|
127
127
|
return this.help();
|
|
128
128
|
}
|
|
129
129
|
const url = args["--url"];
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
130
|
+
const schemaContext = await (0, import_internals.loadSchemaContext)({
|
|
131
|
+
schemaPathFromArg: args["--schema"],
|
|
132
|
+
schemaPathFromConfig: config.schema,
|
|
133
|
+
printLoadMessage: false,
|
|
134
|
+
allowNull: true
|
|
135
|
+
});
|
|
136
|
+
if (schemaContext && !args["--print"]) {
|
|
137
|
+
process.stdout.write((0, import_chunk_SKRR5WT4.dim)(`Prisma schema loaded from ${schemaContext.loadedFromPathForLogMessages}`) + "\n");
|
|
136
138
|
await (0, import_internals.loadEnvFile)({ schemaPath: args["--schema"], printMessage: true, config });
|
|
137
|
-
(0, import_chunk_QOPTDDIH.printDatasource)({ datasourceInfo:
|
|
139
|
+
(0, import_chunk_QOPTDDIH.printDatasource)({ datasourceInfo: (0, import_chunk_74LUB4XX.parseDatasourceInfo)(schemaContext?.primaryDatasource) });
|
|
138
140
|
} else {
|
|
139
141
|
await (0, import_internals.loadEnvFile)({ schemaPath: args["--schema"], printMessage: false, config });
|
|
140
142
|
}
|
|
141
143
|
const fromD1 = Boolean(args["--local-d1"]);
|
|
142
|
-
if (!url && !
|
|
144
|
+
if (!url && !schemaContext && !fromD1) {
|
|
143
145
|
throw new import_chunk_3WC4XD74.NoSchemaFoundError();
|
|
144
146
|
}
|
|
145
|
-
const { firstDatasource, schema, validationWarning } = await (0, import_chunk_G7PJKEOV.z)({ url,
|
|
146
|
-
(input) => input.
|
|
147
|
+
const { firstDatasource, schema, validationWarning } = await (0, import_chunk_G7PJKEOV.z)({ url, schemaContext, fromD1 }).when(
|
|
148
|
+
(input) => input.schemaContext !== null,
|
|
147
149
|
async (input) => {
|
|
148
|
-
const
|
|
149
|
-
const
|
|
150
|
-
datamodel: rawSchema,
|
|
151
|
-
ignoreEnvVarErrors: true
|
|
152
|
-
});
|
|
153
|
-
const previewFeatures = engineConfig.generators.find(({ name }) => name === "client")?.previewFeatures;
|
|
154
|
-
const firstDatasource2 = engineConfig.datasources[0] ? engineConfig.datasources[0] : void 0;
|
|
150
|
+
const previewFeatures = input.schemaContext.generators.find(({ name }) => name === "client")?.previewFeatures;
|
|
151
|
+
const firstDatasource2 = input.schemaContext.primaryDatasource ? input.schemaContext.primaryDatasource : void 0;
|
|
155
152
|
if (input.url) {
|
|
156
153
|
let providerFromSchema = firstDatasource2?.provider;
|
|
157
154
|
if (providerFromSchema === "postgres") {
|
|
158
155
|
providerFromSchema = "postgresql";
|
|
159
156
|
}
|
|
160
157
|
const providerFromUrl = (0, import_internals.protocolToConnectorType)(`${input.url.split(":")[0]}:`);
|
|
161
|
-
const schema2 = (0, import_chunk_RR6BKMNO.replaceOrAddDatasource)(
|
|
158
|
+
const schema2 = (0, import_chunk_RR6BKMNO.replaceOrAddDatasource)(
|
|
159
|
+
this.urlToDatasource(input.url, providerFromSchema),
|
|
160
|
+
input.schemaContext.schemaFiles
|
|
161
|
+
);
|
|
162
162
|
if (providerFromSchema && providerFromUrl && providerFromSchema !== providerFromUrl && Boolean(providerFromSchema === "cockroachdb" && providerFromUrl === "postgresql") === false) {
|
|
163
163
|
throw new Error(
|
|
164
164
|
`The database provider found in --url (${providerFromUrl}) is different from the provider found in the Prisma schema (${providerFromSchema}).`
|
|
@@ -167,7 +167,7 @@ Set composite types introspection depth to 2 levels
|
|
|
167
167
|
return { firstDatasource: firstDatasource2, schema: schema2, validationWarning: void 0 };
|
|
168
168
|
} else if (input.fromD1) {
|
|
169
169
|
const d1Database = await (0, import_internals.locateLocalCloudflareD1)({ arg: "--from-local-d1" });
|
|
170
|
-
const pathToSQLiteFile = import_path.default.relative(
|
|
170
|
+
const pathToSQLiteFile = import_path.default.relative(input.schemaContext.schemaRootDir, d1Database);
|
|
171
171
|
const schema2 = [
|
|
172
172
|
["schema.prisma", this.urlToDatasource(`file:${pathToSQLiteFile}`, "sqlite")]
|
|
173
173
|
];
|
|
@@ -189,11 +189,11 @@ Set composite types introspection depth to 2 levels
|
|
|
189
189
|
}
|
|
190
190
|
} else {
|
|
191
191
|
await (0, import_internals.getConfig)({
|
|
192
|
-
datamodel:
|
|
192
|
+
datamodel: input.schemaContext.schemaFiles,
|
|
193
193
|
ignoreEnvVarErrors: false
|
|
194
194
|
});
|
|
195
195
|
}
|
|
196
|
-
return { firstDatasource: firstDatasource2, schema:
|
|
196
|
+
return { firstDatasource: firstDatasource2, schema: input.schemaContext.schemaFiles, validationWarning: void 0 };
|
|
197
197
|
}
|
|
198
198
|
).when(
|
|
199
199
|
(input) => input.fromD1 === true,
|
|
@@ -224,10 +224,9 @@ ${this.urlToDatasource(`file:${pathToSQLiteFile}`, "sqlite")}`;
|
|
|
224
224
|
return { firstDatasource: config2.datasources[0], schema: schema2, validationWarning: void 0 };
|
|
225
225
|
}
|
|
226
226
|
).run();
|
|
227
|
-
if (
|
|
228
|
-
const schemas = await (0, import_internals.getSchema)(args["--schema"], config.schema);
|
|
227
|
+
if (schemaContext) {
|
|
229
228
|
const modelRegex = /\s*model\s*(\w+)\s*{/;
|
|
230
|
-
const isReintrospection =
|
|
229
|
+
const isReintrospection = schemaContext.schemaFiles.some(([_, schema2]) => !!modelRegex.exec(schema2));
|
|
231
230
|
if (isReintrospection && !args["--force"] && firstDatasource?.provider === "mongodb") {
|
|
232
231
|
throw new Error(`Iterating on one schema using re-introspection with db pull is currently not supported with MongoDB provider.
|
|
233
232
|
You can explicitly ignore and override your current local schema file with ${(0, import_chunk_SKRR5WT4.green)(
|
|
@@ -238,10 +237,10 @@ Some information will be lost (relations, comments, mapped fields, @ignore...),
|
|
|
238
237
|
)} for more info.`);
|
|
239
238
|
}
|
|
240
239
|
}
|
|
241
|
-
const engine = new
|
|
242
|
-
schemaPath: schemaPath ?? void 0
|
|
240
|
+
const engine = new import_chunk_GHZAN2PG.SchemaEngine({
|
|
241
|
+
schemaPath: schemaContext?.schemaPath ?? void 0
|
|
243
242
|
});
|
|
244
|
-
const basedOn = !args["--url"] &&
|
|
243
|
+
const basedOn = !args["--url"] && schemaContext?.primaryDatasource ? ` based on datasource defined in ${(0, import_chunk_SKRR5WT4.underline)(schemaContext.loadedFromPathForLogMessages)}` : "";
|
|
245
244
|
const introspectionSpinner = spinnerFactory(`Introspecting${basedOn}`);
|
|
246
245
|
const before = Math.round(performance.now());
|
|
247
246
|
let introspectionSchema = void 0;
|
|
@@ -249,7 +248,7 @@ Some information will be lost (relations, comments, mapped fields, @ignore...),
|
|
|
249
248
|
try {
|
|
250
249
|
const introspectionResult = await engine.introspect({
|
|
251
250
|
schema: (0, import_internals.toSchemasContainer)(schema),
|
|
252
|
-
baseDirectoryPath:
|
|
251
|
+
baseDirectoryPath: schemaContext?.schemaRootDir ?? process.cwd(),
|
|
253
252
|
force: args["--force"],
|
|
254
253
|
compositeTypeDepth: args["--composite-type-depth"],
|
|
255
254
|
namespaces: args["--schemas"]?.split(",")
|
|
@@ -321,7 +320,6 @@ Or run this command with the ${(0, import_chunk_SKRR5WT4.green)(
|
|
|
321
320
|
console.error(introspectionWarningsMessage.replace(/(\n)/gm, "\n// "));
|
|
322
321
|
}
|
|
323
322
|
} else {
|
|
324
|
-
schemaPath = schemaPath || "schema.prisma";
|
|
325
323
|
if (args["--force"]) {
|
|
326
324
|
await (0, import_chunk_JZ75RIMZ.removeSchemaFiles)(schema);
|
|
327
325
|
}
|
|
@@ -338,8 +336,9 @@ Or run this command with the ${(0, import_chunk_SKRR5WT4.green)(
|
|
|
338
336
|
const modelsAndTypesCountMessage = modelsCount + typesCount > 1 ? `${modelsAndTypesMessage} and wrote them` : `${modelsAndTypesMessage} and wrote it`;
|
|
339
337
|
const renderValidationWarning = validationWarning ? `
|
|
340
338
|
${(0, import_chunk_SKRR5WT4.yellow)(validationWarning)}` : "";
|
|
339
|
+
const introspectedSchemaPath = schemaContext?.loadedFromPathForLogMessages || introspectionSchema.files[0].path;
|
|
341
340
|
introspectionSpinner.success(`Introspected ${modelsAndTypesCountMessage} into ${(0, import_chunk_SKRR5WT4.underline)(
|
|
342
|
-
import_path.default.relative(process.cwd(),
|
|
341
|
+
import_path.default.relative(process.cwd(), introspectedSchemaPath)
|
|
343
342
|
)} in ${(0, import_chunk_SKRR5WT4.bold)((0, import_internals.formatms)(Math.round(performance.now()) - before))}
|
|
344
343
|
${(0, import_chunk_SKRR5WT4.yellow)(introspectionWarningsMessage)}
|
|
345
344
|
${`Run ${(0, import_chunk_SKRR5WT4.green)((0, import_internals.getCommandWithExecutor)("prisma generate"))} to generate Prisma Client.`}${renderValidationWarning}`);
|
|
@@ -26,15 +26,16 @@ 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_U6ZL4ORM_exports = {};
|
|
30
|
+
__export(chunk_U6ZL4ORM_exports, {
|
|
31
31
|
MigrateDiff: () => MigrateDiff
|
|
32
32
|
});
|
|
33
|
-
module.exports = __toCommonJS(
|
|
34
|
-
var import_chunk_ZB5NPOJW = require("./chunk-ZB5NPOJW.js");
|
|
33
|
+
module.exports = __toCommonJS(chunk_U6ZL4ORM_exports);
|
|
35
34
|
var import_chunk_33LPBNDX = require("./chunk-33LPBNDX.js");
|
|
35
|
+
var import_chunk_ZB5NPOJW = require("./chunk-ZB5NPOJW.js");
|
|
36
36
|
var import_chunk_VAJ4VX67 = require("./chunk-VAJ4VX67.js");
|
|
37
|
-
var
|
|
37
|
+
var import_chunk_5Q5BJS5B = require("./chunk-5Q5BJS5B.js");
|
|
38
|
+
var import_chunk_V6PVGSDJ = require("./chunk-V6PVGSDJ.js");
|
|
38
39
|
var import_chunk_G7PJKEOV = require("./chunk-G7PJKEOV.js");
|
|
39
40
|
var import_chunk_SKRR5WT4 = require("./chunk-SKRR5WT4.js");
|
|
40
41
|
var import_chunk_2ESYSVXG = require("./chunk-2ESYSVXG.js");
|
|
@@ -10336,7 +10337,7 @@ var require_package = (0, import_chunk_2ESYSVXG.__commonJS)({
|
|
|
10336
10337
|
"@prisma/fetch-engine": "workspace:*",
|
|
10337
10338
|
"@prisma/generator-helper": "workspace:*",
|
|
10338
10339
|
"@prisma/get-platform": "workspace:*",
|
|
10339
|
-
"@prisma/prisma-schema-wasm": "6.6.0-
|
|
10340
|
+
"@prisma/prisma-schema-wasm": "6.6.0-21.d1dbe8880430b6f753dffc4264de1a7f39e4a15a",
|
|
10340
10341
|
"@prisma/schema-files-loader": "workspace:*",
|
|
10341
10342
|
arg: "5.0.2",
|
|
10342
10343
|
prompts: "2.4.2"
|
|
@@ -11346,7 +11347,7 @@ ${(0, import_chunk_SKRR5WT4.bold)("Examples")}
|
|
|
11346
11347
|
} else if (args["--from-migrations"]) {
|
|
11347
11348
|
from = {
|
|
11348
11349
|
tag: "migrations",
|
|
11349
|
-
|
|
11350
|
+
migrationsList: await (0, import_chunk_V6PVGSDJ.listMigrations)(args["--from-migrations"])
|
|
11350
11351
|
};
|
|
11351
11352
|
} else if (args["--from-local-d1"]) {
|
|
11352
11353
|
const d1Database = await (0, import_internals.locateLocalCloudflareD1)({ arg: "--from-local-d1" });
|
|
@@ -11386,7 +11387,7 @@ ${(0, import_chunk_SKRR5WT4.bold)("Examples")}
|
|
|
11386
11387
|
} else if (args["--to-migrations"]) {
|
|
11387
11388
|
to = {
|
|
11388
11389
|
tag: "migrations",
|
|
11389
|
-
|
|
11390
|
+
migrationsList: await (0, import_chunk_V6PVGSDJ.listMigrations)(args["--to-migrations"])
|
|
11390
11391
|
};
|
|
11391
11392
|
} else if (args["--to-local-d1"]) {
|
|
11392
11393
|
const d1Database = await (0, import_internals.locateLocalCloudflareD1)({ arg: "--to-local-d1" });
|
|
@@ -11395,7 +11396,7 @@ ${(0, import_chunk_SKRR5WT4.bold)("Examples")}
|
|
|
11395
11396
|
url: `file:${d1Database}`
|
|
11396
11397
|
};
|
|
11397
11398
|
}
|
|
11398
|
-
const migrate = new
|
|
11399
|
+
const migrate = new import_chunk_5Q5BJS5B.Migrate();
|
|
11399
11400
|
const captureStdout = new import_chunk_VAJ4VX67.CaptureStdout();
|
|
11400
11401
|
const outputPath = args["--output"];
|
|
11401
11402
|
const isOutputDefined = Boolean(outputPath);
|
|
@@ -0,0 +1,76 @@
|
|
|
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_V6PVGSDJ_exports = {};
|
|
30
|
+
__export(chunk_V6PVGSDJ_exports, {
|
|
31
|
+
listMigrations: () => listMigrations
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(chunk_V6PVGSDJ_exports);
|
|
34
|
+
var import_promises = __toESM(require("node:fs/promises"));
|
|
35
|
+
var import_node_path = __toESM(require("node:path"));
|
|
36
|
+
async function listMigrations(migrationsDirectoryPath) {
|
|
37
|
+
const baseDir = migrationsDirectoryPath;
|
|
38
|
+
const lockfileName = "migration_lock.toml";
|
|
39
|
+
const lockfileContent = await import_promises.default.readFile(import_node_path.default.join(migrationsDirectoryPath, lockfileName), { encoding: "utf-8" }).catch(() => null);
|
|
40
|
+
const lockfile = {
|
|
41
|
+
path: lockfileName,
|
|
42
|
+
content: lockfileContent
|
|
43
|
+
};
|
|
44
|
+
let entries = [];
|
|
45
|
+
try {
|
|
46
|
+
entries = await import_promises.default.readdir(migrationsDirectoryPath, { withFileTypes: true, recursive: false }).catch((_) => []);
|
|
47
|
+
} catch (error) {
|
|
48
|
+
if (error.code === "ENOENT") {
|
|
49
|
+
return {
|
|
50
|
+
baseDir,
|
|
51
|
+
lockfile,
|
|
52
|
+
migrationDirectories: []
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
throw error;
|
|
56
|
+
}
|
|
57
|
+
const migrationDirectories = [];
|
|
58
|
+
for (const entry of entries.filter((entry2) => entry2.isDirectory())) {
|
|
59
|
+
const migrationPath = import_node_path.default.join(baseDir, entry.name);
|
|
60
|
+
const migrationFileName = "migration.sql";
|
|
61
|
+
const migrationFileContent = await import_promises.default.readFile(import_node_path.default.join(migrationPath, migrationFileName), { encoding: "utf-8" }).then((content) => ({ tag: "ok", value: content })).catch((error) => ({ tag: "error", value: error }));
|
|
62
|
+
migrationDirectories.push({
|
|
63
|
+
path: entry.name,
|
|
64
|
+
migrationFile: {
|
|
65
|
+
path: migrationFileName,
|
|
66
|
+
content: migrationFileContent
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
const sortedMigrations = migrationDirectories.sort((a, b) => a.path.localeCompare(b.path));
|
|
71
|
+
return {
|
|
72
|
+
baseDir,
|
|
73
|
+
lockfile,
|
|
74
|
+
migrationDirectories: sortedMigrations
|
|
75
|
+
};
|
|
76
|
+
}
|