drizzle-kit 0.18.0-9c3e0b3 → 0.18.0
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/index.js +46 -58
- package/package.json +1 -1
- package/readme.md +14 -1
package/index.js
CHANGED
|
@@ -590,7 +590,7 @@ var require_command = __commonJS({
|
|
|
590
590
|
var EventEmitter = require("events").EventEmitter;
|
|
591
591
|
var childProcess = require("child_process");
|
|
592
592
|
var path3 = require("path");
|
|
593
|
-
var
|
|
593
|
+
var fs6 = require("fs");
|
|
594
594
|
var process3 = require("process");
|
|
595
595
|
var { Argument: Argument2, humanReadableArgName } = require_argument();
|
|
596
596
|
var { CommanderError: CommanderError2 } = require_error();
|
|
@@ -1021,11 +1021,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1021
1021
|
const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
|
|
1022
1022
|
function findFile(baseDir, baseName) {
|
|
1023
1023
|
const localBin = path3.resolve(baseDir, baseName);
|
|
1024
|
-
if (
|
|
1024
|
+
if (fs6.existsSync(localBin))
|
|
1025
1025
|
return localBin;
|
|
1026
1026
|
if (sourceExt.includes(path3.extname(baseName)))
|
|
1027
1027
|
return void 0;
|
|
1028
|
-
const foundExt = sourceExt.find((ext2) =>
|
|
1028
|
+
const foundExt = sourceExt.find((ext2) => fs6.existsSync(`${localBin}${ext2}`));
|
|
1029
1029
|
if (foundExt)
|
|
1030
1030
|
return `${localBin}${foundExt}`;
|
|
1031
1031
|
return void 0;
|
|
@@ -1037,7 +1037,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1037
1037
|
if (this._scriptPath) {
|
|
1038
1038
|
let resolvedScriptPath;
|
|
1039
1039
|
try {
|
|
1040
|
-
resolvedScriptPath =
|
|
1040
|
+
resolvedScriptPath = fs6.realpathSync(this._scriptPath);
|
|
1041
1041
|
} catch (err2) {
|
|
1042
1042
|
resolvedScriptPath = this._scriptPath;
|
|
1043
1043
|
}
|
|
@@ -18243,31 +18243,31 @@ var require_node2 = __commonJS({
|
|
|
18243
18243
|
var configAbsolutePath = walkForTsConfig(cwd);
|
|
18244
18244
|
return configAbsolutePath ? path3.resolve(configAbsolutePath) : void 0;
|
|
18245
18245
|
}
|
|
18246
|
-
function walkForTsConfig(directory,
|
|
18247
|
-
if (
|
|
18248
|
-
|
|
18246
|
+
function walkForTsConfig(directory, existsSync4) {
|
|
18247
|
+
if (existsSync4 === void 0) {
|
|
18248
|
+
existsSync4 = fs32.existsSync;
|
|
18249
18249
|
}
|
|
18250
18250
|
var configPath = path3.join(directory, "./tsconfig.json");
|
|
18251
|
-
if (
|
|
18251
|
+
if (existsSync4(configPath)) {
|
|
18252
18252
|
return configPath;
|
|
18253
18253
|
}
|
|
18254
18254
|
var parentDirectory = path3.join(directory, "../");
|
|
18255
18255
|
if (directory === parentDirectory) {
|
|
18256
18256
|
return void 0;
|
|
18257
18257
|
}
|
|
18258
|
-
return walkForTsConfig(parentDirectory,
|
|
18258
|
+
return walkForTsConfig(parentDirectory, existsSync4);
|
|
18259
18259
|
}
|
|
18260
18260
|
exports2.walkForTsConfig = walkForTsConfig;
|
|
18261
|
-
function loadTsconfig(configFilePath,
|
|
18262
|
-
if (
|
|
18263
|
-
|
|
18261
|
+
function loadTsconfig(configFilePath, existsSync4, readFileSync4) {
|
|
18262
|
+
if (existsSync4 === void 0) {
|
|
18263
|
+
existsSync4 = fs32.existsSync;
|
|
18264
18264
|
}
|
|
18265
18265
|
if (readFileSync4 === void 0) {
|
|
18266
18266
|
readFileSync4 = function(filename) {
|
|
18267
18267
|
return fs32.readFileSync(filename, "utf8");
|
|
18268
18268
|
};
|
|
18269
18269
|
}
|
|
18270
|
-
if (!
|
|
18270
|
+
if (!existsSync4(configFilePath)) {
|
|
18271
18271
|
return void 0;
|
|
18272
18272
|
}
|
|
18273
18273
|
var configString = readFileSync4(configFilePath);
|
|
@@ -18280,10 +18280,10 @@ var require_node2 = __commonJS({
|
|
|
18280
18280
|
}
|
|
18281
18281
|
var currentDir = path3.dirname(configFilePath);
|
|
18282
18282
|
var extendedConfigPath = path3.join(currentDir, extendedConfig);
|
|
18283
|
-
if (extendedConfig.indexOf("/") !== -1 && extendedConfig.indexOf(".") !== -1 && !
|
|
18283
|
+
if (extendedConfig.indexOf("/") !== -1 && extendedConfig.indexOf(".") !== -1 && !existsSync4(extendedConfigPath)) {
|
|
18284
18284
|
extendedConfigPath = path3.join(currentDir, "node_modules", extendedConfig);
|
|
18285
18285
|
}
|
|
18286
|
-
var base = loadTsconfig(extendedConfigPath,
|
|
18286
|
+
var base = loadTsconfig(extendedConfigPath, existsSync4, readFileSync4) || {};
|
|
18287
18287
|
if (base.compilerOptions && base.compilerOptions.baseUrl) {
|
|
18288
18288
|
var extendsDir = path3.dirname(extendedConfig);
|
|
18289
18289
|
base.compilerOptions.baseUrl = path3.join(extendsDir, base.compilerOptions.baseUrl);
|
|
@@ -18925,7 +18925,7 @@ var require_old = __commonJS({
|
|
|
18925
18925
|
"node_modules/.pnpm/fs.realpath@1.0.0/node_modules/fs.realpath/old.js"(exports) {
|
|
18926
18926
|
var pathModule = require("path");
|
|
18927
18927
|
var isWindows = process.platform === "win32";
|
|
18928
|
-
var
|
|
18928
|
+
var fs6 = require("fs");
|
|
18929
18929
|
var DEBUG = process.env.NODE_DEBUG && /fs/.test(process.env.NODE_DEBUG);
|
|
18930
18930
|
function rethrow() {
|
|
18931
18931
|
var callback;
|
|
@@ -18990,7 +18990,7 @@ var require_old = __commonJS({
|
|
|
18990
18990
|
base = m[0];
|
|
18991
18991
|
previous = "";
|
|
18992
18992
|
if (isWindows && !knownHard[base]) {
|
|
18993
|
-
|
|
18993
|
+
fs6.lstatSync(base);
|
|
18994
18994
|
knownHard[base] = true;
|
|
18995
18995
|
}
|
|
18996
18996
|
}
|
|
@@ -19008,7 +19008,7 @@ var require_old = __commonJS({
|
|
|
19008
19008
|
if (cache && Object.prototype.hasOwnProperty.call(cache, base)) {
|
|
19009
19009
|
resolvedLink = cache[base];
|
|
19010
19010
|
} else {
|
|
19011
|
-
var stat =
|
|
19011
|
+
var stat = fs6.lstatSync(base);
|
|
19012
19012
|
if (!stat.isSymbolicLink()) {
|
|
19013
19013
|
knownHard[base] = true;
|
|
19014
19014
|
if (cache)
|
|
@@ -19023,8 +19023,8 @@ var require_old = __commonJS({
|
|
|
19023
19023
|
}
|
|
19024
19024
|
}
|
|
19025
19025
|
if (linkTarget === null) {
|
|
19026
|
-
|
|
19027
|
-
linkTarget =
|
|
19026
|
+
fs6.statSync(base);
|
|
19027
|
+
linkTarget = fs6.readlinkSync(base);
|
|
19028
19028
|
}
|
|
19029
19029
|
resolvedLink = pathModule.resolve(previous, linkTarget);
|
|
19030
19030
|
if (cache)
|
|
@@ -19061,7 +19061,7 @@ var require_old = __commonJS({
|
|
|
19061
19061
|
base = m[0];
|
|
19062
19062
|
previous = "";
|
|
19063
19063
|
if (isWindows && !knownHard[base]) {
|
|
19064
|
-
|
|
19064
|
+
fs6.lstat(base, function(err2) {
|
|
19065
19065
|
if (err2)
|
|
19066
19066
|
return cb(err2);
|
|
19067
19067
|
knownHard[base] = true;
|
|
@@ -19089,7 +19089,7 @@ var require_old = __commonJS({
|
|
|
19089
19089
|
if (cache && Object.prototype.hasOwnProperty.call(cache, base)) {
|
|
19090
19090
|
return gotResolvedLink(cache[base]);
|
|
19091
19091
|
}
|
|
19092
|
-
return
|
|
19092
|
+
return fs6.lstat(base, gotStat);
|
|
19093
19093
|
}
|
|
19094
19094
|
function gotStat(err2, stat) {
|
|
19095
19095
|
if (err2)
|
|
@@ -19106,10 +19106,10 @@ var require_old = __commonJS({
|
|
|
19106
19106
|
return gotTarget(null, seenLinks[id], base);
|
|
19107
19107
|
}
|
|
19108
19108
|
}
|
|
19109
|
-
|
|
19109
|
+
fs6.stat(base, function(err3) {
|
|
19110
19110
|
if (err3)
|
|
19111
19111
|
return cb(err3);
|
|
19112
|
-
|
|
19112
|
+
fs6.readlink(base, function(err4, target) {
|
|
19113
19113
|
if (!isWindows)
|
|
19114
19114
|
seenLinks[id] = target;
|
|
19115
19115
|
gotTarget(err4, target);
|
|
@@ -19141,9 +19141,9 @@ var require_fs = __commonJS({
|
|
|
19141
19141
|
realpath.realpathSync = realpathSync;
|
|
19142
19142
|
realpath.monkeypatch = monkeypatch;
|
|
19143
19143
|
realpath.unmonkeypatch = unmonkeypatch;
|
|
19144
|
-
var
|
|
19145
|
-
var origRealpath =
|
|
19146
|
-
var origRealpathSync =
|
|
19144
|
+
var fs6 = require("fs");
|
|
19145
|
+
var origRealpath = fs6.realpath;
|
|
19146
|
+
var origRealpathSync = fs6.realpathSync;
|
|
19147
19147
|
var version = process.version;
|
|
19148
19148
|
var ok = /^v[0-5]\./.test(version);
|
|
19149
19149
|
var old = require_old();
|
|
@@ -19181,12 +19181,12 @@ var require_fs = __commonJS({
|
|
|
19181
19181
|
}
|
|
19182
19182
|
}
|
|
19183
19183
|
function monkeypatch() {
|
|
19184
|
-
|
|
19185
|
-
|
|
19184
|
+
fs6.realpath = realpath;
|
|
19185
|
+
fs6.realpathSync = realpathSync;
|
|
19186
19186
|
}
|
|
19187
19187
|
function unmonkeypatch() {
|
|
19188
|
-
|
|
19189
|
-
|
|
19188
|
+
fs6.realpath = origRealpath;
|
|
19189
|
+
fs6.realpathSync = origRealpathSync;
|
|
19190
19190
|
}
|
|
19191
19191
|
}
|
|
19192
19192
|
});
|
|
@@ -20036,7 +20036,7 @@ var require_common2 = __commonJS({
|
|
|
20036
20036
|
function ownProp(obj, field) {
|
|
20037
20037
|
return Object.prototype.hasOwnProperty.call(obj, field);
|
|
20038
20038
|
}
|
|
20039
|
-
var
|
|
20039
|
+
var fs6 = require("fs");
|
|
20040
20040
|
var path3 = require("path");
|
|
20041
20041
|
var minimatch2 = require_minimatch();
|
|
20042
20042
|
var isAbsolute = require("path").isAbsolute;
|
|
@@ -20095,7 +20095,7 @@ var require_common2 = __commonJS({
|
|
|
20095
20095
|
self2.stat = !!options.stat;
|
|
20096
20096
|
self2.noprocess = !!options.noprocess;
|
|
20097
20097
|
self2.absolute = !!options.absolute;
|
|
20098
|
-
self2.fs = options.fs ||
|
|
20098
|
+
self2.fs = options.fs || fs6;
|
|
20099
20099
|
self2.maxLength = options.maxLength || Infinity;
|
|
20100
20100
|
self2.cache = options.cache || /* @__PURE__ */ Object.create(null);
|
|
20101
20101
|
self2.statCache = options.statCache || /* @__PURE__ */ Object.create(null);
|
|
@@ -47087,15 +47087,15 @@ var require_lib3 = __commonJS({
|
|
|
47087
47087
|
"node_modules/.pnpm/pgpass@1.0.5/node_modules/pgpass/lib/index.js"(exports, module2) {
|
|
47088
47088
|
"use strict";
|
|
47089
47089
|
var path3 = require("path");
|
|
47090
|
-
var
|
|
47090
|
+
var fs6 = require("fs");
|
|
47091
47091
|
var helper = require_helper();
|
|
47092
47092
|
module2.exports = function(connInfo, cb) {
|
|
47093
47093
|
var file = helper.getFileName();
|
|
47094
|
-
|
|
47094
|
+
fs6.stat(file, function(err2, stat) {
|
|
47095
47095
|
if (err2 || !helper.usePgPass(stat, file)) {
|
|
47096
47096
|
return cb(void 0);
|
|
47097
47097
|
}
|
|
47098
|
-
var st =
|
|
47098
|
+
var st = fs6.createReadStream(file);
|
|
47099
47099
|
helper.getPassword(connInfo, st, cb);
|
|
47100
47100
|
});
|
|
47101
47101
|
};
|
|
@@ -47143,7 +47143,7 @@ var require_pg_connection_string = __commonJS({
|
|
|
47143
47143
|
"node_modules/.pnpm/pg-connection-string@2.5.0/node_modules/pg-connection-string/index.js"(exports, module2) {
|
|
47144
47144
|
"use strict";
|
|
47145
47145
|
var url = require("url");
|
|
47146
|
-
var
|
|
47146
|
+
var fs6 = require("fs");
|
|
47147
47147
|
function parse(str) {
|
|
47148
47148
|
if (str.charAt(0) === "/") {
|
|
47149
47149
|
var config = str.split(" ");
|
|
@@ -47192,13 +47192,13 @@ var require_pg_connection_string = __commonJS({
|
|
|
47192
47192
|
config.ssl = {};
|
|
47193
47193
|
}
|
|
47194
47194
|
if (config.sslcert) {
|
|
47195
|
-
config.ssl.cert =
|
|
47195
|
+
config.ssl.cert = fs6.readFileSync(config.sslcert).toString();
|
|
47196
47196
|
}
|
|
47197
47197
|
if (config.sslkey) {
|
|
47198
|
-
config.ssl.key =
|
|
47198
|
+
config.ssl.key = fs6.readFileSync(config.sslkey).toString();
|
|
47199
47199
|
}
|
|
47200
47200
|
if (config.sslrootcert) {
|
|
47201
|
-
config.ssl.ca =
|
|
47201
|
+
config.ssl.ca = fs6.readFileSync(config.sslrootcert).toString();
|
|
47202
47202
|
}
|
|
47203
47203
|
switch (config.sslmode) {
|
|
47204
47204
|
case "disable": {
|
|
@@ -51042,7 +51042,7 @@ var logSuggestionsAndReturn = async ({
|
|
|
51042
51042
|
};
|
|
51043
51043
|
|
|
51044
51044
|
// src/cli/index.ts
|
|
51045
|
-
|
|
51045
|
+
init_serializer();
|
|
51046
51046
|
var printVersions = () => {
|
|
51047
51047
|
console.log(`${source_default.gray(versions())}
|
|
51048
51048
|
`);
|
|
@@ -51121,18 +51121,10 @@ var dbPushMysqlCommand = new Command("push:mysql").option(
|
|
|
51121
51121
|
assertOrmCoreVersion();
|
|
51122
51122
|
const { mysqlPushIntrospect: mysqlPushIntrospect2, connectToMySQL: connectToMySQL2 } = (init_mysqlIntrospect(), __toCommonJS(mysqlIntrospect_exports));
|
|
51123
51123
|
const drizzleConfig = drizzleConfigFromFile(options.config);
|
|
51124
|
-
|
|
51125
|
-
|
|
51126
|
-
|
|
51127
|
-
|
|
51128
|
-
process.exit(0);
|
|
51129
|
-
}
|
|
51130
|
-
}
|
|
51131
|
-
} else {
|
|
51132
|
-
if (!fs6.existsSync(drizzleConfig.schema)) {
|
|
51133
|
-
(0, import_hanji6.render)(`[${source_default.blue("i")}] No schema file in ${drizzleConfig.schema} was found`);
|
|
51134
|
-
process.exit(0);
|
|
51135
|
-
}
|
|
51124
|
+
const fileNames = prepareFilenames(drizzleConfig.schema);
|
|
51125
|
+
if (fileNames.length === 0) {
|
|
51126
|
+
(0, import_hanji6.render)(`[${source_default.blue("i")}] No schema file in ${drizzleConfig.schema} was found`);
|
|
51127
|
+
process.exit(0);
|
|
51136
51128
|
}
|
|
51137
51129
|
const connection = await connectToMySQL2(drizzleConfig);
|
|
51138
51130
|
const filterConfig = drizzleConfig.tablesFilter;
|
|
@@ -51166,11 +51158,7 @@ var dbPushMysqlCommand = new Command("push:mysql").option(
|
|
|
51166
51158
|
"THIS ACTION WILL CAUSE DATA LOSS AND CANNOT BE REVERTED\n"
|
|
51167
51159
|
)
|
|
51168
51160
|
);
|
|
51169
|
-
console.log(
|
|
51170
|
-
source_default.white(
|
|
51171
|
-
"Do you still want to push changes?"
|
|
51172
|
-
)
|
|
51173
|
-
);
|
|
51161
|
+
console.log(source_default.white("Do you still want to push changes?"));
|
|
51174
51162
|
const { status, data } = await (0, import_hanji6.render)(
|
|
51175
51163
|
new Select([
|
|
51176
51164
|
"No, abort",
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
DrizzleKit - is a CLI migrator tool for DrizzleORM. It is probably one and only tool that lets you completely automatically generate SQL migrations and covers ~95% of the common cases like deletions and renames by prompting user input.
|
|
4
4
|
<https://github.com/drizzle-team/drizzle-kit-mirror> - is a mirror repository for issues.
|
|
5
5
|
|
|
6
|
+
## Documentation
|
|
7
|
+
|
|
8
|
+
Check the full documenation on [the website](https://orm.drizzle.team/kit-docs/overview)
|
|
9
|
+
|
|
6
10
|
### How it works
|
|
7
11
|
|
|
8
12
|
`drizzle-kit` will traverse `schema folder` or `schema file`, generate schema snapshot and compare it to the previous version, if there's one.
|
|
@@ -61,8 +65,17 @@ npm install -D drizzle-kit
|
|
|
61
65
|
|
|
62
66
|
Running with CLI options
|
|
63
67
|
|
|
68
|
+
```jsonc
|
|
69
|
+
// package.json
|
|
70
|
+
{
|
|
71
|
+
"scripts": {
|
|
72
|
+
"generate": "drizzle-kit generate:pg --out migrations-folder --schema src/db/schema.ts"
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
64
77
|
```shell
|
|
65
|
-
|
|
78
|
+
npm run generate
|
|
66
79
|
```
|
|
67
80
|
|
|
68
81
|
### Configuration
|